All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <compudj@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>, linux-kernel@vger.kernel.org
Subject: Re: Thread flags modified without set_thread_flag() (non atomically)
Date: Thu, 01 Mar 2007 11:59:07 -0800	[thread overview]
Message-ID: <45E7308B.3050106@google.com> (raw)
In-Reply-To: <20070301014523.e45c3cc5.akpm@linux-foundation.org>

Andrew Morton wrote:
> On Thu, 1 Mar 2007 10:34:51 +0100 Haavard Skinnemoen <hskinnemoen@atmel.com> wrote:
>
>   
>>> On Mon, 26 Feb 2007 12:10:37 -0800 Mathieu Desnoyers <compudj@google.com> wrote:
>>>       
>>>> avr32/kernel/ptrace.c:          ti->flags |= _TIF_BREAKPOINT;
>>>>         
>>> No, I don't immediately see anything in the flush_old_exec() code path
>>> which tells us that nobody else can look up this thread_info (or be holding
>>> a ref to it) in this context.
>>>
>>>
>>>       
>>>> avr32/kernel/ptrace.c:                  ti->flags |= TIF_SINGLE_STEP;
>>>>         
>>> heh.  Haarvard, you got a bug.
>>>       
>> Heh, yeah. That would indeed explain some strange gdb behaviour. It
>> will only trigger when single-stepping into an exception or interrupt
>> handler so thanks for pointing it out; I would have had a hard time
>> figuring it out on my own...
>>     
>
> yup, tricky.
>
> If there's a lesson here, it is "don't provide #defines in the header for
> both versions".
>
>   

Hrm, but the bitmask version is useful (and correctly used) whenever
the flag is read and tested.

The proper way to do this would be to change every use the _TIF_* flag 
in a flag comparison
for a call to test_ti_thread_flag(). I wonder if gcc optimizes multiple 
constant test_bit() applying
on the same variable linked by logical and/or so it becomes a single 
read and a small set of comparisons.

> The block code does a similar thing:
>
> #define REQ_RW          (1 << __REQ_RW)
> #define REQ_FAILFAST    (1 << __REQ_FAILFAST)
> #define REQ_SORTED      (1 << __REQ_SORTED)
> #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER)
>
> and I've caught Jens using the wrong identifier at least twice in the past.
>
> It's better I think to just provide #defines for the bit offsets and
> open-code the shifting if needed.  Like PG_foo and BH_Foo.
>
>   
>> I don't think either of those need to be atomic though, since both of
>> them happen in monitor mode with interrupts disabled.
>>     
>
> That's true until you implement SMP ;)
>   


  parent reply	other threads:[~2007-03-01 19:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-26 20:10 Thread flags modified without set_thread_flag() (non atomically) Mathieu Desnoyers
2007-03-01  6:03 ` Andrew Morton
2007-03-01  6:23   ` David Miller
2007-03-01  8:17     ` Andrew Morton
2007-03-01  9:34   ` Haavard Skinnemoen
2007-03-01  9:45     ` Andrew Morton
2007-03-01 10:14       ` Haavard Skinnemoen
2007-03-01 15:13         ` Haavard Skinnemoen
2007-03-01 19:59       ` Mathieu Desnoyers [this message]
2007-03-01 22:41         ` Andrew Morton
2007-03-05 16:30           ` Kyle Moffett
2007-03-05 14:40   ` Andi Kleen
2007-03-05 22:04     ` Andrew Morton
2007-03-06  4:35     ` Mathieu Desnoyers

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=45E7308B.3050106@google.com \
    --to=compudj@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=hskinnemoen@atmel.com \
    --cc=linux-kernel@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.