Re: [RFC][PATCH 5/8] x86/mm: fix exception table comments
From: Sean Christopherson
Date: Mon Sep 10 2018 - 16:43:24 EST
On Fri, 2018-09-07 at 14:51 -0700, Dave Hansen wrote:
> >
> > >
> > > + Â* Only do the expensive exception table search when we might be at
> > > + Â* risk of a deadlock:
> > > + Â* 1. We failed to acquire mmap_sem, and
> > > + Â* 2. The access was an explicit kernel-mode access
> > > + Â*ÂÂÂÂ(X86_PF_USER=0).
> > Might be worth reminding the reader that X86_PF_USER will be set in
> > sw_error_code for implicit accesses. ÂI saw "explicit" and my mind
> > immediately jumped to hw_error_code for whatever reason. ÂE.g.:
> >
> > * 2. The access was an explicit kernel-mode access (we set X86_PF_USER
> > * Â Âin sw_error_code for implicit kernel-mode accesses).
> Yeah, that was not worded well.ÂÂIs this better?
>
> >
> > ÂÂÂÂÂÂÂÂÂ* Only do the expensive exception table search when we might be at
> > ÂÂÂÂÂÂÂÂÂ* risk of a deadlock:
> > ÂÂÂÂÂÂÂÂÂ* 1. We failed to acquire mmap_sem, and
> > ÂÂÂÂÂÂÂÂÂ* 2. The access was an explicit kernel-mode access.ÂÂAn access
> > ÂÂÂÂÂÂÂÂÂ*ÂÂÂÂfrom user-mode will X86_PF_USER=1 set via hw_error_code or
> > ÂÂÂÂÂÂÂÂÂ*ÂÂÂÂset in sw_error_code if it were an implicit kernel-mode
> > ÂÂÂÂÂÂÂÂÂ*ÂÂÂÂaccess that originated in user mode.
For me, mentioning hw_error_code just muddies the waters, e.g. why is
hw_error_code mentioned when it's not checked in the code? ÂComments
alone won't help someone that's reading this code and doesn't understand
that hardware sets X86_PF_USER for user-mode accesses. ÂMaybe this?
* 2. The access was an explicit kernel-mode access.ÂÂX86_PF_USER
*ÂÂÂÂis set in sw_error_code for both user-mode accesses and
*ÂÂÂÂimplicit kernel-mode accesses that originated in user mode.