Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1467483 > unrolled thread

[PATCH] staging/lustre: avoid zero buf for the first time

Started byShawn Lin <shawn.lin@rock-chips.com>
First post2016-08-22 11:00 +0200
Last post2016-08-22 12:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] staging/lustre: avoid zero buf for the first time Shawn Lin <shawn.lin@rock-chips.com> - 2016-08-22 11:00 +0200
    Re: [PATCH] staging/lustre: avoid zero buf for the first time Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-08-22 12:10 +0200

#1467483 — [PATCH] staging/lustre: avoid zero buf for the first time

FromShawn Lin <shawn.lin@rock-chips.com>
Date2016-08-22 11:00 +0200
Subject[PATCH] staging/lustre: avoid zero buf for the first time
Message-ID<s8Tfj-42v-11@gated-at.bofh.it>
We only need to zero it when repeating in order to
avoid old garbage. Let's improve it by moving this
before we repeat the calculation to save some cpu
cycle.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/staging/lustre/lustre/obdclass/llog.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index 1784ca0..923061f 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -248,8 +248,6 @@ repeat:
 		CDEBUG(D_OTHER, "index: %d last_index %d\n",
 		       index, last_index);
 
-		/* get the buf with our target record; avoid old garbage */
-		memset(buf, 0, LLOG_CHUNK_SIZE);
 		last_offset = cur_offset;
 		rc = llog_next_block(lpi->lpi_env, loghandle, &saved_index,
 				     index, &cur_offset, buf, LLOG_CHUNK_SIZE);
@@ -275,8 +273,11 @@ repeat:
 			if (rec->lrh_index == 0) {
 				/* probably another rec just got added? */
 				rc = 0;
-				if (index <= loghandle->lgh_last_idx)
+				if (index <= loghandle->lgh_last_idx) {
+					/* avoid old garbage */
+					memset(buf, 0, LLOG_CHUNK_SIZE);
 					goto repeat;
+				}
 				goto out; /* no more records */
 			}
 			if (rec->lrh_len == 0 ||
-- 
2.3.7

[toc] | [next] | [standalone]


#1467522

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2016-08-22 12:10 +0200
Message-ID<s8Ul4-4Vk-33@gated-at.bofh.it>
In reply to#1467483
On Mon, Aug 22, 2016 at 04:46:04PM +0800, Shawn Lin wrote:
> We only need to zero it when repeating in order to
> avoid old garbage. Let's improve it by moving this
> before we repeat the calculation to save some cpu
> cycle.
> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

Have you noticed a change with this in a benchmark?

If not, is it really worth it?

I need an ack from the lustre developers before taking patches like
this...

thanks,

greg k-h

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web