linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging/lustre: avoid zero buf for the first time
@ 2016-08-22  8:46 Shawn Lin
  2016-08-22 10:04 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Lin @ 2016-08-22  8:46 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, lustre-devel, devel
  Cc: Greg Kroah-Hartman, linux-kernel, Shawn Lin

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging/lustre: avoid zero buf for the first time
  2016-08-22  8:46 [PATCH] staging/lustre: avoid zero buf for the first time Shawn Lin
@ 2016-08-22 10:04 ` Greg Kroah-Hartman
  2016-08-26 19:48   ` Oleg Drokin
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2016-08-22 10:04 UTC (permalink / raw)
  To: Shawn Lin; +Cc: Oleg Drokin, Andreas Dilger, lustre-devel, devel, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging/lustre: avoid zero buf for the first time
  2016-08-22 10:04 ` Greg Kroah-Hartman
@ 2016-08-26 19:48   ` Oleg Drokin
  0 siblings, 0 replies; 3+ messages in thread
From: Oleg Drokin @ 2016-08-26 19:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Shawn Lin, Andreas Dilger, lustre-devel, devel, linux-kernel

Hello!

On Aug 22, 2016, at 6:04 AM, Greg Kroah-Hartman wrote:

> 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?

The other problem is we would need to remember to memset it
should there be more paths jumping to the repeat label
which might be easy to miss,
so we are probably better off without this patch.

> I need an ack from the lustre developers before taking patches like
> this...
> 
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-26 19:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-22  8:46 [PATCH] staging/lustre: avoid zero buf for the first time Shawn Lin
2016-08-22 10:04 ` Greg Kroah-Hartman
2016-08-26 19:48   ` Oleg Drokin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).