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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 1ECEFC433EF for ; Fri, 3 Sep 2021 01:39:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 97CEF60EE6 for ; Fri, 3 Sep 2021 01:39:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 97CEF60EE6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id DC143900002; Thu, 2 Sep 2021 21:39:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D71978D0001; Thu, 2 Sep 2021 21:39:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C396D900002; Thu, 2 Sep 2021 21:39:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id B07458D0001 for ; Thu, 2 Sep 2021 21:39:40 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 71CF127702 for ; Fri, 3 Sep 2021 01:39:40 +0000 (UTC) X-FDA: 78544555320.27.F4047A5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf06.hostedemail.com (Postfix) with ESMTP id DAE87801A89C for ; Fri, 3 Sep 2021 01:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630633179; 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=W00JWM6LN9F7vwzH1kt4Gm8FUt1a8dgaBLhIJfS2rZ4=; b=JbEJETddD5F3kQFUN8F3RiPrSM2Rw8aKORQCb3S2McvN+s/Oym6wGV4BGg9vAbxVnxysTY Gk8L446sQsNXUrVya/k3kK3ccDuUOH9j9aeTZiuhMCZpa1E5dVveVth9+LB8XG2ilv9W9J YFlSjpNBx/8zxXx5F89+rskwVMfshLI= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-XRgltmdMMoKAeFFAF7IvjA-1; Thu, 02 Sep 2021 21:39:38 -0400 X-MC-Unique: XRgltmdMMoKAeFFAF7IvjA-1 Received: by mail-qk1-f197.google.com with SMTP id h186-20020a3785c3000000b00425f37f792aso4802937qkd.22 for ; Thu, 02 Sep 2021 18:39:38 -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=W00JWM6LN9F7vwzH1kt4Gm8FUt1a8dgaBLhIJfS2rZ4=; b=aum+s+KEq5peHT3OOxFEUNVDwh/m61sliH942CQZqOzRd27McqdjmOyl++AnQov8cL J8CtzDOew9rw/xuKL/0YQEGEOctCBJwCqmcnOwganng96ieCEeJJDGKwlsgCRfK8yE10 aZmqhy9jxi9cJhu/wZfFByblLqNw69Qgsx+XXAjGcUjY/CnT8vJVP/JQJVb9ruHEejIp LJruoHRwUi+g7iVGZVYsieeRsS+vHIQpJBT25Bo7II1oUb6V5O0j6Uo1xFEjOGFldR3u QQcmxWvmX2CmYiNY5YMkFi0YYK7VloQCXhAoKbII19pi9GNUn17rhO/br6YoK4WkpJou HyJw== X-Gm-Message-State: AOAM530DZ89XEyft+ApZVppCxnA5d5G8DmbCxO9xzT69PYdDKpqbSNKQ 2lZg7sqRtfTsNcCj5lbEfAQbZLdUQ4+y/c33g++fvZQXYe4cCniF5+gMEqcu3ktTlg6WF7fxYfw M4b7Q0TTB7F0= X-Received: by 2002:a0c:8d0f:: with SMTP id r15mr1019996qvb.1.1630633175505; Thu, 02 Sep 2021 18:39:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv/7UQawEfBRbROuQEdhFsWgpMnvcwVEApFke+TCOv/QDPFLZuHkOyvez5rBrSXsAr9VdM+A== X-Received: by 2002:a0c:8d0f:: with SMTP id r15mr1019966qvb.1.1630633175180; Thu, 02 Sep 2021 18:39:35 -0700 (PDT) Received: from t490s ([2607:fea8:56a3:500::ad7f]) by smtp.gmail.com with ESMTPSA id f28sm2859082qkk.10.2021.09.02.18.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 18:39:34 -0700 (PDT) Date: Thu, 2 Sep 2021 21:39:32 -0400 From: Peter Xu To: Alistair Popple Cc: Hugh Dickins , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A . Shutemov" , Jerome Glisse , Andrea Arcangeli , Miaohe Lin , Yang Shi , Matthew Wilcox , Mike Rapoport , David Hildenbrand Subject: Re: [PATCH v2 4/5] mm: Add zap_skip_check_mapping() helper Message-ID: References: <20210902201721.52796-1-peterx@redhat.com> <20210902201819.53343-1-peterx@redhat.com> <1771631.QAr93JHi05@nvdebian> MIME-Version: 1.0 In-Reply-To: <1771631.QAr93JHi05@nvdebian> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JbEJETdd; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf06.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: rspam03 X-Rspamd-Queue-Id: DAE87801A89C X-Stat-Signature: tg6siqka3eywe84m1ee8uht6dnzem1b8 X-HE-Tag: 1630633179-608205 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 Fri, Sep 03, 2021 at 10:58:53AM +1000, Alistair Popple wrote: > On Friday, 3 September 2021 6:18:19 AM AEST Peter Xu wrote: > > Use the helper for the checks. Rename "check_mapping" into "zap_mapping" > > because "check_mapping" looks like a bool but in fact it stores the mapping > > itself. When it's set, we check the mapping (it must be non-NULL). When it's > > cleared we skip the check, which works like the old way. > > > > Move the duplicated comments to the helper too. > > > > Signed-off-by: Peter Xu > > --- > > include/linux/mm.h | 15 ++++++++++++++- > > mm/memory.c | 29 ++++++----------------------- > > 2 files changed, 20 insertions(+), 24 deletions(-) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 69259229f090..81e402a5fbc9 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1720,10 +1720,23 @@ extern void user_shm_unlock(size_t, struct ucounts *); > > * Parameter block passed down to zap_pte_range in exceptional cases. > > */ > > struct zap_details { > > - struct address_space *check_mapping; /* Check page->mapping if set */ > > + struct address_space *zap_mapping; /* Check page->mapping if set */ > > struct page *single_page; /* Locked page to be unmapped */ > > }; > > > > +/* > > + * We set details->zap_mappings when we want to unmap shared but keep private > > + * pages. Return true if skip zapping this page, false otherwise. > > + */ > > +static inline bool > > +zap_skip_check_mapping(struct zap_details *details, struct page *page) > > +{ > > + if (!details || !page) > > + return false; > > + > > + return details->zap_mapping != page_rmapping(page); > > Shouldn't this check still be > details->zap_mapping && details->zap_mapping != page_rmapping(page)? > > Previously we wouldn't skip zapping pages if even_cows == true (ie. > details->check_mapping == NULL). With this change the check when > even_cows == true becomes NULL != page_rmapping(page). Doesn't this mean we > will now skip zapping any pages with a mapping when even_cows == true? Yes I think so. Thanks for pointing that out, Alistair, I'll fix in v3. But frankly I really think we should simply have that flag I used to introduce. It'll make everything much clearer. -- Peter Xu