All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luben Tuikov <luben_tuikov@adaptec.com>
To: Tejun Heo <htejun@gmail.com>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	James.Bottomley@steeleye.com, albertcc@tw.ibm.com,
	linux-scsi@vger.kernel.org
Subject: Re: [RFC] SCSI EH document
Date: Tue, 30 Aug 2005 10:50:54 -0400	[thread overview]
Message-ID: <4314724E.5020400@adaptec.com> (raw)
In-Reply-To: <43143943.2050802@gmail.com>

On 08/30/05 06:47, Tejun Heo wrote:
>   Hi, Luben.
> 
> Luben Tuikov wrote:
> 
>>On 08/29/05 05:14, Tejun Heo wrote:
>>
>>
>>>>Both all the list-heads need to be cleared, otherwise there may be list 
>>>>corruption next time the element is added to the list_head.
>>>>
>>>
>>>
>>> scmd->eh_entry is never used as list head.  It's always used as list 
>>>entry.  So, technically, it needs not be cleared, I think.  No?  The 
>>>problem we had was w/ shost->eh_cmd_q not being cleared.
>>
>>
>>In your "strategy" routine:
>>
>>	...
>>	spin_lock_irqsave(shost->host_lock, flags);
>>	list_splice_init(&shost->eh_cmd_q, &error_q);
>>	spin_unlock_irqrestore(shost->host_lock, flags);
>>	...
>>
>>	loop {
>>		...
>>		list_del_init(&cmd->eh_entry);
>>		...
>>	}
>>
>>A good policy to follow is:
>>	1. Never leave prev/next pointing somewhere where
>>		- you don't belong, or
>>		- where you don't know existance is in place.
>>	2. Someone (memory release?) may do:
>>		if (!list_empty(cmd->eh_entry))
>>			Refuse to free the memory.
>>	Which is often the case to check if the object belongs to
>>	a list. (You shouldn't have to do this but case pointed only for
>>	illustrational purposes.)
>>
>>   Luben
>>
> 
> 
>   The reason why I explicitly stated that clearing scmd->eh_entry was 
> not currently necessary was that libata had infinite loop bug due to 
> eh_cmd_q related memory corruption and I wanted to make sure that not 
> clearing scmd->eh_entry wasn't the cause.
> 
>   Previously, libata didn't clear both shost->eh_cmd_q and 
> scmd->eh_entry.  I posted an one liner which cleared shost->eh_cmd_q and 
> I believe that's the fix for the problem.  However, Mark Lord is still 
> having lockup problems with libata which, I suspect, is because libata 
> doesn't handle PM's properly.  But, as I'm not very sure, I wanted to 
> make sure that libata's not clearing scmd->eh_cmd_q is not causing the 
> lockup.

Ah, ok, thanks for clarifying.

>   I agree that, as a policy, always clearing list_head's are nice if 
> it's not in the *real* hot path where reducing several assignments 
> matter, but as it's not strictly/technically necessary, it might be 
> difficult to enforce as long as functions which don't clear list_head 
> are there.

Unless you're running on anything but a 6502, one or 10 assignments
would make absolutely no difference.  Been there, done that (including
the 6502 ;-) ).

Plus the fact that today's compilers are so much more advanced
than 20 years ago, you'll see no "speedup" difference from the number
of assignments.

Also compare the processor time to assign a value to the processor
time it does anything else, while the disk is doing IO.

What matters is complexity, big-oh notation.

Now, as a matter of practice and experience, programmers
develop certain _patterns_ of programming certain constructs, like
for example linked list manipulation.  Those practices, (patterns),
have proven bugless over many years of programming.  This is
what Jeff is talking about.

While it is true that
	list_del(&cmd->eh_entry);
	release command (cmd)
is equivalent to
	list_del_init(&cmd->eh_entry);
	release command(cmd),
you will find that after time, when this code is augmented
and some block written between the list_del() and release command,
that block may take the wrong assumption causing you to have
mysterious bugs.

	Luben


  reply	other threads:[~2005-08-30 14:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-26  3:53 [RFC] SCSI EH document Tejun Heo
2005-08-26 21:34 ` Jeff Garzik
2005-08-29  9:14   ` Tejun Heo
2005-08-29 13:55     ` Luben Tuikov
2005-08-30 10:47       ` Tejun Heo
2005-08-30 14:50         ` Luben Tuikov [this message]
2005-08-29 18:50     ` Jeff Garzik
2005-08-29 19:49       ` Matthew Wilcox
2005-08-29 19:49         ` Jeff Garzik
2005-08-29 21:38       ` Tejun Heo
2005-08-29 22:27         ` Jeff Garzik
2005-08-26 21:36 ` Luben Tuikov
2005-09-07  8:04 ` Jeff Garzik
2005-09-07 11:22   ` Tejun Heo
2005-09-07 13:12     ` Luben Tuikov
2005-09-07 14:00     ` James Bottomley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4314724E.5020400@adaptec.com \
    --to=luben_tuikov@adaptec.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=albertcc@tw.ibm.com \
    --cc=htejun@gmail.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.