mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Possible error in fs/buffer.c
@ 2004-04-01 15:43 Robert W. Maloy
  2004-04-02  0:26 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Robert W. Maloy @ 2004-04-01 15:43 UTC (permalink / raw)
  To: linux-kernel

	While code surfing I found what appears to be a problem with the 
following code in fs/buffer.c {function mark_buffer_inode_dirty}: 

       if (list_empty(&bh->b_assoc_buffers))
                buffer_insert_list(&buffer_mapping->private_lock,
                                bh, &mapping->private_list);

	From my research, the job of buffer_insert_list is to place the list 
contents of bh->b_assoc_buffers onto the list mapping->private list. 
The above code segment will only call buffer_insert_list if 
b_assoc_buffers is empty. Why waste the time, and resources 
attempting to add an empty list to the end of private_list?

	If this is a problem, then there are two possibilities for fixing 
this code: 

    1) This was just a mistake
	add "!" in the if, this only adds the list if there is 
        something to add.
		- if (list_empty(&bh->b_assoc_buffers))
		+ if (!list_empty(&bh->b_assoc_buffers))

    2) Some of the assoc buffers may already be on the private_list. 
If this is a possibility then this routine will need more work.
	


Please CC me on all responses since I am not a member of this list.

-- 
Cheers
Rob Maloy
r.w.maloy@acm.org
(410) 854-6637

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

* Re: Possible error in fs/buffer.c
  2004-04-01 15:43 Possible error in fs/buffer.c Robert W. Maloy
@ 2004-04-02  0:26 ` Andrew Morton
  2004-04-02 10:46   ` Robert W. Maloy
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2004-04-02  0:26 UTC (permalink / raw)
  To: r.w.maloy; +Cc: linux-kernel

"Robert W. Maloy" <r.w.maloy@acm.org> wrote:
>
> 	While code surfing I found what appears to be a problem with the 
> following code in fs/buffer.c {function mark_buffer_inode_dirty}: 
> 
>        if (list_empty(&bh->b_assoc_buffers))
>                 buffer_insert_list(&buffer_mapping->private_lock,
>                                 bh, &mapping->private_list);

This is saying "is the buffer is not on any list, then place it on the
mapping's list now.  If the buffer _is_ already on some list then we know
it must already be on mapping->private_list, so we have nothing to do".

Re-dirtying an already-dirty buffer is an extremely common case, and here
we look for an opportunity to avoid dirtying a cacheline or two.


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

* Re: Possible error in fs/buffer.c
  2004-04-02  0:26 ` Andrew Morton
@ 2004-04-02 10:46   ` Robert W. Maloy
  0 siblings, 0 replies; 3+ messages in thread
From: Robert W. Maloy @ 2004-04-02 10:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

> Andrew Morton wrote:
> This is saying "is the buffer is not on any list, then place it on
> the mapping's list now.  If the buffer _is_ already on some list
> then we know it must already be on mapping->private_list, so we
> have nothing to do".
>
> Re-dirtying an already-dirty buffer is an extremely common case,
> and here we look for an opportunity to avoid dirtying a cacheline
> or two.

This makes some since except that
     buffer_insert_list(&buffer_mapping->private_lock,
              bh, &mapping->private_list);

 only adds &bh->b_assoc_buffers to the end of mapping->private_list 
not the buffer itself.

-- 
Cheers
Rob Maloy
r.w.maloy@acm.org
(410) 854-6637

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

end of thread, other threads:[~2004-04-02 10:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-01 15:43 Possible error in fs/buffer.c Robert W. Maloy
2004-04-02  0:26 ` Andrew Morton
2004-04-02 10:46   ` Robert W. Maloy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®