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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YJVQEGSLil7wYhEe@t490s>
Date:   Fri, 7 May 2021 10:34:56 -0400
From:   Peter Xu <peterx@...hat.com>
To:     John Hubbard <jhubbard@...dia.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Matthew Wilcox <willy@...radead.org>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Hugh Dickins <hughd@...gle.com>, Jan Kara <jack@...e.cz>,
        Kirill Shutemov <kirill@...temov.name>,
        Jason Gunthorpe <jgg@...dia.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Kirill Tkhai <ktkhai@...tuozzo.com>,
        Michal Hocko <mhocko@...e.com>,
        Oleg Nesterov <oleg@...hat.com>, Jann Horn <jannh@...gle.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Matthew Wilcox <willy@...radead.org>,
        Andrea Arcangeli <aarcange@...hat.com>
Subject: Re: [PATCH 3/3] mm: gup: pack has_pinned in MMF_HAS_PINNED

On Thu, May 06, 2021 at 11:42:59PM -0700, John Hubbard wrote:
> > +#define MMF_HAS_PINNED		28	/* FOLL_PIN has run, never cleared */
> 
> How about this instead, so that we effectively retain the comment block
> that is otherwise being deleted from mm.h:
> 
> /*
>  * MMF_HAS_PINNED: Whether this mm has pinned any pages.  This can be either
>  * replaced in the future by mm.pinned_vm when it becomes stable, or grow into a
>  * counter on its own. We're aggresive on this bit for now: even if the pinned
>  * pages were unpinned later on, we'll still keep this bit set for the lifecycle
>  * of this mm, just for simplicity.
>  */
> #define MMF_HAS_PINNED		28	/* FOLL_PIN ran. Never cleared. */

Sure, good to know the comment is still valid!

> > @@ -1292,8 +1292,8 @@ static __always_inline long __get_user_pages_locked(struct mm_struct *mm,
> >   		BUG_ON(*locked != 1);
> >   	}
> > -	if (flags & FOLL_PIN && !atomic_read(&mm->has_pinned))
> > -		atomic_set(&mm->has_pinned, 1);
> > +	if (flags & FOLL_PIN && !test_bit(MMF_HAS_PINNED, &mm->flags))
> > +		set_bit(MMF_HAS_PINNED, &mm->flags);
> 
> I expect this suggestion to be controversial, but I'm going to float it
> anyway. The above is a little less clear than it used to be, *and* it is
> in two places so far, so how about factoring out a tiny subroutine, like this:

Definitely less "controversial" than expected, isn't it? ;)

Thanks for the suggestion, it looks much better indeed.  Also I'll rename the
helper to mm_set_has_pinned_flag() as suggested by Matthew.

-- 
Peter Xu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ