lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f22d86810910140234h26e40257ufc29ffa4f00291de@mail.gmail.com>
Date:	Wed, 14 Oct 2009 02:34:33 -0700
From:	"Leonidas ." <leonidas137@...il.com>
To:	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: How to check whether executing in atomic context?

On Wed, Oct 14, 2009 at 2:21 AM, Leonidas . <leonidas137@...il.com> wrote:
> On Tue, Oct 13, 2009 at 11:36 PM, Leonidas . <leonidas137@...il.com> wrote:
>> Hi List,
>>
>> I am working on a profiler kind of module, the exported apis of my
>> module can be
>> called from process context and interrupt context as well. Depending on the
>> context I am called in, I need to call sleepable/nonsleepable variants
>> of my internal
>> bookkeeping functions.
>>
>> I am aware of in_interrupt() call which can be used to check current
>> context and take action
>> accordingly.
>>
>> Is there any api which can help figure out whether we are executing
>> while hold a spinlock? I.e
>> an api which can help figure out sleepable/nonsleepable context? If it
>> is not there, what can
>> be done for writing the same? Any pointers will be helpful.
>>
>> -Leo.
>>
>
>  While searching through the sources, I found this,
>
>  97/*
>  98 * Are we running in atomic context?  WARNING: this macro cannot
>  99 * always detect atomic context; in particular, it cannot know about
>  100 * held spinlocks in non-preemptible kernels.  Thus it should not be
>  101 * used in the general case to determine whether sleeping is possible.
>  102 * Do not use in_atomic() in driver code.
>  103 */
>  104#define in_atomic()     ((preempt_count() & ~PREEMPT_ACTIVE) !=
> PREEMPT_INATOMIC_BASE)
>  105
>
> this just complicates the matter, right? This does not work in general
> case but I think this
> will always work if the kernel is preemptible.
>
> Is there no way to write a generic macro?
>
>
> -Leo.
>

Just saw this:

http://thread.gmane.org/gmane.linux.kernel.wireless.general/12716

Looks like, there is no way to figure out that.


-Leo.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ