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=-18.7 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,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 C8172C433EF for ; Fri, 24 Sep 2021 10:11:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 64815610F7 for ; Fri, 24 Sep 2021 10:11:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 64815610F7 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 D397C6B006C; Fri, 24 Sep 2021 06:11:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE847900002; Fri, 24 Sep 2021 06:11:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB05C6B0073; Fri, 24 Sep 2021 06:11:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id AC8726B006C for ; Fri, 24 Sep 2021 06:11:20 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 728BC18298B0E for ; Fri, 24 Sep 2021 10:11:20 +0000 (UTC) X-FDA: 78622049520.39.E6D551D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 1D289600198D for ; Fri, 24 Sep 2021 10:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632478279; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/CCJWmEkOKRF8YEuH0GEFrZjGS+trpPLyEMqqAo/hqo=; b=IIplvRp8Icym7zzRs3uDgvIe9RyTCS9OS/EL4NU1YZ4s9YeXwjCAn4v9ol/EPHHj8B+SnV sNPJ4CfMQuN6OCUlL8EZ7iQJCicJVMKJcj4UOpP3RoQtwXJszWoHwyYdTg2q+3K83+vv4c r1CJMzTNxwpfVQeQxALiBbzwgPotG2g= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-304--e-ngGX1OfyWvBUtZCLBNw-1; Fri, 24 Sep 2021 06:11:18 -0400 X-MC-Unique: -e-ngGX1OfyWvBUtZCLBNw-1 Received: by mail-wr1-f69.google.com with SMTP id z2-20020a5d4c82000000b0015b140e0562so7652572wrs.7 for ; Fri, 24 Sep 2021 03:11:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=/CCJWmEkOKRF8YEuH0GEFrZjGS+trpPLyEMqqAo/hqo=; b=dGNYag+cy2tNUUhUUHnXSEQK148zKOltGOzPdd4oVtH6YKYOvbE9y6zhCwnncx3KAj hoQqTqiimhV5z4d5Mxfvi3y5O81jVtLobbur1BVpa2CNQLXK6yPEMSJ439E+P6cBeXTI 3+C6I21UbX24LZcqHnB4DhQN4/tibT4LzRpcTmfThhwNVyYoaCKfI4e70pxvlT9bTYHY z/q+LXsyB2gJtcNemv2eh8xKYydHFMTNhtSqpWpjpT3G+eytLNvYMkukMxE0zLrPzzmp VczCN+R4Qj28gnZapY52Hl9TtyXBbwyjMYBZm/UJEf1mzv8HLDENZYFY1n0wwKUlgjvI JkOQ== X-Gm-Message-State: AOAM530utyX5gtFS1PU1chpo3DBXacoNomgmzvcvhWgu9r1PLQ5ZrgF7 846RMHItPojxurTaK8DU2Iy4E8vcYv7UyUz6PNLiy8CqONciI+iIwHefXWKtLL0t4sb3CcV48aG sGgQ55BrEHdY= X-Received: by 2002:adf:e30d:: with SMTP id b13mr10469239wrj.438.1632478277220; Fri, 24 Sep 2021 03:11:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI2MmdDtWgYWK7tqU5QWe0PLlYrgQvbJr7j8j/MPpSSLuqsdwiXXXKfUh50RCbadioWrL+zg== X-Received: by 2002:adf:e30d:: with SMTP id b13mr10469221wrj.438.1632478277057; Fri, 24 Sep 2021 03:11:17 -0700 (PDT) Received: from [192.168.3.132] (p5b0c61fc.dip0.t-ipconnect.de. [91.12.97.252]) by smtp.gmail.com with ESMTPSA id i9sm12457009wmi.44.2021.09.24.03.11.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Sep 2021 03:11:16 -0700 (PDT) Subject: Re: [PATCH v4 4/4] mm: Add zap_skip_check_mapping() helper To: Peter Xu , linux-kernel@vger.kernel.org, Andrew Morton , linux-mm@kvack.org Cc: Hugh Dickins , Liam Howlett , Mike Rapoport , Alistair Popple , Matthew Wilcox , Yang Shi , "Kirill A . Shutemov" , Jerome Glisse , Miaohe Lin , Andrea Arcangeli References: <20210915181456.10739-1-peterx@redhat.com> <20210915181538.11288-1-peterx@redhat.com> From: David Hildenbrand Organization: Red Hat Message-ID: <12fa0797-05ea-aede-eeae-826133f03499@redhat.com> Date: Fri, 24 Sep 2021 12:11:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210915181538.11288-1-peterx@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1D289600198D X-Stat-Signature: n8akck8a4bu1oqey86w7os36imyq11xo Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IIplvRp8; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf14.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1632478279-974850 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 15.09.21 20:15, 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. > > Reviewed-by: Alistair Popple > Signed-off-by: Peter Xu > --- > include/linux/mm.h | 16 +++++++++++++++- > mm/memory.c | 29 ++++++----------------------- > 2 files changed, 21 insertions(+), 24 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index d1126f731221..ed44f31615d9 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1721,10 +1721,24 @@ 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) I agree with Hugh that the name of this helper is suboptimal. What about inverting the conditions and getting static inline bool should_zap_page() { ... } The calling code is then if (unlikely(!should_zap_page(details, page))) continue; I don't really like renaming "zap_mapping", again, because it's contained within "struct zap_details" already. Factoring this out into a helper sounds like a good idea to me. Clear case of code de-duplication. -- Thanks, David / dhildenb