mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: "Jörn Engel" <joern@logfs.org>
Cc: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	target-devel <target-devel@vger.kernel.org>
Subject: Re: [PATCH 3/3] target: simplify target_wait_for_sess_cmds()
Date: Tue, 14 May 2013 23:05:02 -0700	[thread overview]
Message-ID: <1368597902.14770.11.camel@haakon3.risingtidesystems.com> (raw)
In-Reply-To: <20130515021909.GA3716@logfs.org>

On Tue, 2013-05-14 at 22:19 -0400, Jörn Engel wrote:
> On Tue, 14 May 2013 20:05:30 -0700, Nicholas A. Bellinger wrote:
> > On Tue, 2013-05-14 at 12:29 -0400, Jörn Engel wrote:
> > > On Mon, 13 May 2013 20:08:44 -0700, Nicholas A. Bellinger wrote:
> > > > On Mon, 2013-05-13 at 18:00 -0400, Jörn Engel wrote:
> > > > > 
> > > > > I agree that the overhead doesn't matter.  The msleep(100) spells this
> > > > > out rather explicitly.  What does matter is that a) the patch retains
> > > > > old behaviour with much simpler code and b) it fixes a race that kills
> > > > > the machine.  I can live without a, but very much want to keep b. ;)
> > > > 
> > > > Fucking around with ->sess_cmd_lock during each loop of ->sess_cmd_list
> > > > in target_wait_for_sess_cmds is not simpler code..
> > > 
> > > I could argue that fucking around with ->sess_cmd_lock during each
> > > loop is simpler than the communication through cmd_wait_set and
> > > cmd_wait_comp.  But simplicity is ultimately subjective and we can
> > > argue all day.
> > 
> > What I don't like is the endless loop in target_wait_for_sess_cmds()
> > that acquires and releases ->sess_cmd_lock for every command, with a
> > hard-coded msleep thrown in.
> 
> Not for every command.  If the list is empty, it waits exactly 0x.  If
> all the commands finish within 100ms, it waits exactly 1x.  Otherwise
> it waits for as long as it takes, plus up to 100ms.
> 
> I agree this sucks, but the alternative was more code and we got it
> wrong.  The old adage is that for every 20 lines of code you add a
> bug, and these 32 lines definitely had one.  Which is why I almost
> always prefer less code.
> 

I'd rather judge by the code itself, rather than by some artificial line
count.  Especially when the few lines we're talking about reinstating
are two pieces of initialization and single list_splice().

> There is more to complexity than mere line count.  Your original code
> also made it impossible to judge the correctness of the code without
> using grep.  My loop is "either the commands eventually all complete,
> or we hang forever."  Your loop was "grep for cmd_wait_set, grep for
> cmd_wait_comp and check every function that lights up.  Assuming all
> of that is correct, either the commands eventually all complete, or we
> hang forever."
> 
> But if I cannot convince you, I guess we have to live with the bug
> as-is.

Fine.  I'll post a patch shortly for the version that I'd prefer, and
you can include it into the test setup at your leisure.

Feel free to complain if you think it's logically incorrect.

>   Telling management that I have to spend another week of my
> time and several weeks of testing for a bug that is already fixed is a
> hard sell.  And even if I had that much free time and my wife didn't
> complain, I don't have the necessary equipment.  So the decision is
> yours.  You are the maintainer and have every right to block my patch.
>

Not sure what to say here.  The end result for how the logic actually
works is AFAICT the same, I just don't like the extra lock acquire +
releases and the hardcoded msleep.

--nab


      reply	other threads:[~2013-05-15  6:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-13 20:30 [PATCH 0/3] target: Fix two races leading to use-after-free Joern Engel
2013-05-13 20:30 ` [PATCH 1/3] target: removed unused transport_state flag Joern Engel
2013-05-13 20:30 ` [PATCH 2/3] target: close target_put_sess_cmd() vs. core_tmr_abort_task() race v5 Joern Engel
2013-05-13 23:02   ` Nicholas A. Bellinger
2013-05-14 19:04   ` Greg Kroah-Hartman
2013-05-15  3:07     ` Nicholas A. Bellinger
2013-05-13 20:30 ` [PATCH 3/3] target: simplify target_wait_for_sess_cmds() Joern Engel
2013-05-13 23:00   ` Nicholas A. Bellinger
2013-05-13 22:00     ` Jörn Engel
2013-05-14  3:08       ` Nicholas A. Bellinger
2013-05-14 16:29         ` Jörn Engel
2013-05-15  3:05           ` Nicholas A. Bellinger
2013-05-15  2:19             ` Jörn Engel
2013-05-15  6:05               ` Nicholas A. Bellinger [this message]

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=1368597902.14770.11.camel@haakon3.risingtidesystems.com \
    --to=nab@linux-iscsi.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joern@logfs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=target-devel@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 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®