[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171106105601.4evsp63q5xb2drc2@dhcp22.suse.cz>
Date: Mon, 6 Nov 2017 11:56:01 +0100
From: Michal Hocko <mhocko@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Bart Van Assche <Bart.VanAssche@....com>,
"yang.s@...baba-inc.com" <yang.s@...baba-inc.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"joe@...ches.com" <joe@...ches.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"mingo@...hat.com" <mingo@...hat.com>
Subject: Re: [PATCH] mm: use in_atomic() in print_vma_addr()
On Mon 06-11-17 11:43:54, Michal Hocko wrote:
> On Mon 06-11-17 11:05:58, Peter Zijlstra wrote:
> > On Sun, Nov 05, 2017 at 09:19:46AM +0100, Michal Hocko wrote:
> > > [CC Peter]
> > >
> > > On Fri 03-11-17 20:09:49, Bart Van Assche wrote:
> > > > On Fri, 2017-11-03 at 11:02 -0700, Andrew Morton wrote:
> > > > > Also, checkpatch says
> > > > >
> > > > > WARNING: use of in_atomic() is incorrect outside core kernel code
> > > > > #43: FILE: mm/memory.c:4491:
> > > > > + if (in_atomic())
> > > > >
> > > > > I don't recall why we did that, but perhaps this should be revisited?
> > > >
> > > > Is the comment above in_atomic() still up-to-date? From <linux/preempt.h>:
> > > >
> > > > /*
> > > > * Are we running in atomic context? WARNING: this macro cannot
> > > > * always detect atomic context; in particular, it cannot know about
> > > > * held spinlocks in non-preemptible kernels. Thus it should not be
> > > > * used in the general case to determine whether sleeping is possible.
> > > > * Do not use in_atomic() in driver code.
> > > > */
> > > > #define in_atomic() (preempt_count() != 0)
> > >
> > > I can still see preempt_disable NOOP for !CONFIG_PREEMPT_COUNT kernels
> > > which makes me think this is still a valid comment.
> >
> > Yes the comment is very much accurate.
>
> Which suggests that print_vma_addr might be problematic, right?
> Shouldn't we do trylock on mmap_sem instead?
I might be missing something but the check seems to be broken. The
original commit by Ingo e8bff74afbdb ("x86: fix "BUG: sleeping function
called from invalid context" in print_vma_addr()") relied on elevated
preempt count by preempt_conditional_sti which is gone for quite some
time. First replaced by explicit preempt_disable in d99e1bd175f4
("x86/entry/traps: Refactor preemption and interrupt flag handling").
So unless I am missing something this check doesn't work and we should
rather do the trylock thing.
--
Michal Hocko
SUSE Labs
Powered by blists - more mailing lists