From: Minchan Kim <minchan.kim@gmail.com>
To: "홍신 shin hong" <hongshin@gmail.com>
Cc: linux-mm@kvack.org
Subject: Re: BUG? misused atomic instructions in mm/swapfile.c
Date: Thu, 3 Sep 2009 15:14:54 +0900 [thread overview]
Message-ID: <20090903151454.c0bd1bcd.minchan.kim@barrios-desktop> (raw)
In-Reply-To: <2014bcab0909022255i53e9f72t4c131c648fb4754@mail.gmail.com>
On Thu, 3 Sep 2009 14:55:22 +0900
i??i? shin hong <hongshin@gmail.com> wrote:
> Hello. I am reporting atomic instructions usages
> which are suspected to be misused in mm/swapfile.c
> of Linux 2.6.30.5.
>
> I do not have much background on mm
> so that I am not certain whether it is correct or not.
> But I hope this report is helpful. Please examine the code.
>
> In try_to_use(), setup_swap_extents(), and SYSCALL_DEFINE2(),
> there are following codes:
First of all, I can find it only in try_to_use.
Do I miss somewhere?
>
> if (atomic_read(&start_mm->mm_users) == 1) {
> mmput(start_mm) ;
> start_mm = &init_mm ;
> atomic_inc(&init_mm.mm_users) ;
> }
>
> It first checks start_mm->mm_users and then increments its value by one.
>
> If one of these functions is executed in two different threads
> for the same start_mm concurrently,
> mmput(start_mm) can be executed twice as result of race.
Is is a matter?
I looked over the code.
Couldn't atomic_dec_and_test avoid your concern?
void mmput(struct mm_struct *mm)
{
might_sleep();
if (atomic_dec_and_test(&mm->mm_users)) {
...
>
> I think it would be better to combine two atomic operations
> into one atomic operation (e.g. atomic_cmpxchg).
>
> Thank you.
>
> Sincerely
> Shin Hong
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Kind regards,
Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-09-03 6:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-03 5:55 홍신 shin hong
2009-09-03 6:14 ` Minchan Kim [this message]
2009-09-03 11:51 ` Hugh Dickins
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=20090903151454.c0bd1bcd.minchan.kim@barrios-desktop \
--to=minchan.kim@gmail.com \
--cc=hongshin@gmail.com \
--cc=linux-mm@kvack.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