From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C59CDC433ED for ; Fri, 7 May 2021 14:35:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37BBE610F7 for ; Fri, 7 May 2021 14:35:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37BBE610F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 77FBB6B00BC; Fri, 7 May 2021 10:35:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7528F6B00BD; Fri, 7 May 2021 10:35:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CC446B00BE; Fri, 7 May 2021 10:35:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id 33FF86B00BC for ; Fri, 7 May 2021 10:35:02 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CA188180ACF84 for ; Fri, 7 May 2021 14:35:01 +0000 (UTC) X-FDA: 78114682002.14.B4D0BCB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 67EB65090484 for ; Fri, 7 May 2021 14:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rgJM7rcwdpqiWcKrLGLGEmzPVdrTnOgLXsD7YCtl+rM=; b=fxQS5AKe49Xp8jSSjeBptOd5++SHBpP/o4/kHTPyoNglkaLYuqnd7q46w41H1QzCe0Sp+Q FnZpDxpkOYCXhnn/LVkVvP/U9NO2s3WAbmOA8TRDty67gPWY8psBhexKLSWBAt+eK16ZJ4 MVKOtQK8eK1rwowGHcsocd3hcbkvEP0= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-WWfKbfr2N36b8H-Ya1NNDA-1; Fri, 07 May 2021 10:34:59 -0400 X-MC-Unique: WWfKbfr2N36b8H-Ya1NNDA-1 Received: by mail-qk1-f200.google.com with SMTP id o14-20020a05620a130eb02902ea53a6ef80so6158187qkj.6 for ; Fri, 07 May 2021 07:34:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rgJM7rcwdpqiWcKrLGLGEmzPVdrTnOgLXsD7YCtl+rM=; b=rBa78ybtazx03tCgbOUHN3gIfX8QySuolMzEJC7Hz4S1BSEXzUkP+t1I5dYV09omfM kVPuPBZ9heYBemOe1RIVbgxHzJ2gXhLueHe1neHq5Nag8/2SdBYjPNv4LEUPOBA/INVE oAI+PL4HIXGEGjM50HJB/Vk18OdrVNVkgsXx26XH4ZBdBP1FMbzV+Yg90OPkmR08Ckhj HX4dXPX5VDzlQfgebMODMyPsD7xVwkpkbt8QCoDjVKZ0h9t/rsX/EwojlyC2uGcMbFIe jxjBpvpFx53eFXavQ5PnVm3B5wEPx9+pUnioPyOAaHZ/w8Id/IXlivrkgfTHvAwD+ebi 2n4A== X-Gm-Message-State: AOAM530rPZEh3po5SaaCa6AT8e9PFnCcy8BMRAZVWQ0tYC+KtfidzP+d NCv+wpYE+VYK9pAKtJw4z6D+sLmoLW4+HH0dcyI7c2y0lyZu301ijO1qyUSdTO3oykPbPaP0H6T qEkvUoebxYOk= X-Received: by 2002:a05:6214:486:: with SMTP id ay6mr9888767qvb.18.1620398098775; Fri, 07 May 2021 07:34:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/F5OaDko+vZfUHXfSJhKl5aMCi2Pl+T2EqSPFraTJjI2uArYbRY1NZZFlC9bDPNCS/RWtDQ== X-Received: by 2002:a05:6214:486:: with SMTP id ay6mr9888747qvb.18.1620398098551; Fri, 07 May 2021 07:34:58 -0700 (PDT) Received: from t490s (bras-base-toroon474qw-grc-72-184-145-4-219.dsl.bell.ca. [184.145.4.219]) by smtp.gmail.com with ESMTPSA id 67sm4999948qtf.54.2021.05.07.07.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:34:57 -0700 (PDT) Date: Fri, 7 May 2021 10:34:56 -0400 From: Peter Xu To: John Hubbard , Linus Torvalds , Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Jan Kara , Kirill Shutemov , Jason Gunthorpe , Andrew Morton , Kirill Tkhai , Michal Hocko , Oleg Nesterov , Jann Horn , Linus Torvalds , Matthew Wilcox , Andrea Arcangeli Subject: Re: [PATCH 3/3] mm: gup: pack has_pinned in MMF_HAS_PINNED Message-ID: References: <20210506232537.165788-1-peterx@redhat.com> <20210506232537.165788-4-peterx@redhat.com> <69055843-185d-20ea-213b-10494a2f7246@nvidia.com> MIME-Version: 1.0 In-Reply-To: <69055843-185d-20ea-213b-10494a2f7246@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: 67EB65090484 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fxQS5AKe; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf01.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam04 X-Stat-Signature: fwah68x6xwi58fpud7q4jbwutz9d8rur Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620398099-545046 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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