From: Andrew Morton <akpm@osdl.org>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] Enforce "unsigned long flags;" when spinlocking
Date: Fri, 20 Oct 2006 11:46:40 -0700 [thread overview]
Message-ID: <20061020114640.9231b18f.akpm@osdl.org> (raw)
In-Reply-To: <20061020131544.GC17199@martell.zuzino.mipt.ru>
On Fri, 20 Oct 2006 17:15:44 +0400
Alexey Dobriyan <adobriyan@gmail.com> wrote:
> Make it break or warn if you pass to spin_lock_irqsave() and friends
> something different from "unsigned long flags;". Suprisingly large amount of
> these was caught by recent commit c53421b18f205c5f97c604ae55c6a921f034b0f6 .
>
> Idea is largely from FRV typechecking.
>
> Note #1: checking with sparse is still needed, because a driver can save and
> pass around flags or something. So far patch is very intrusive.
> Note #2: techically, we should break only if sizeof(flags) < sizeof(unsigned long),
> but hey, there is opportunity to escalate. Thus !=
> Note #3: yes, would break every single buggy out-of-tree module.
>
This is a pretty ugly-looking patch.
>
> + BUILD_BUG_ON(sizeof(flags) != sizeof(unsigned long)); \
> + typecheck(unsigned long, flags); \
> ...
> + BUILD_BUG_ON(sizeof(flags) != sizeof(unsigned long)); \
> + typecheck(unsigned long, flags); \
> ...
> + BUILD_BUG_ON(sizeof(flags) != sizeof(unsigned long)); \
> + typecheck(unsigned long, flags); \
> ...
> + BUILD_BUG_ON(sizeof(flags) != sizeof(unsigned long)); \
> + typecheck(unsigned long, flags); \
> ...
> + BUILD_BUG_ON(sizeof(flags) != sizeof(unsigned long)); \
> + typecheck(unsigned long, flags); \
> ...
starting to see a pattern here?
If we're going to do this then a helper macro build_check_irq_flags() would
help clean things up. It will also allow us to centralise the
warning-vs-error policy decision.
I'm not sure that we need both, do we? If it spits a warning then it'll
get fixed soon enough.
next prev parent reply other threads:[~2006-10-20 18:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-20 13:15 Alexey Dobriyan
2006-10-20 18:46 ` Andrew Morton [this message]
2006-10-20 23:38 ` Alexey Dobriyan
2006-10-21 0:32 ` Andrew Morton
2006-10-23 17:37 ` [PATCH v2] " Alexey Dobriyan
2006-10-21 0:13 ` [PATCH 3/3] " Alexey Dobriyan
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=20061020114640.9231b18f.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=adobriyan@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome