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=-17.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 61AFAC43214 for ; Thu, 2 Sep 2021 07:28:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0B5B6109E for ; Thu, 2 Sep 2021 07:28:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F0B5B6109E 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 217878D0002; Thu, 2 Sep 2021 03:28:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A0098D0001; Thu, 2 Sep 2021 03:28:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0404F8D0002; Thu, 2 Sep 2021 03:28:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id E2BB38D0001 for ; Thu, 2 Sep 2021 03:28:49 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8449C181F2281 for ; Thu, 2 Sep 2021 07:28:49 +0000 (UTC) X-FDA: 78541806378.34.79C1050 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 14C913000103 for ; Thu, 2 Sep 2021 07:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630567728; 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=bWmLpJjiGr7OPwqTTslMad67D5ZXIJqk/nCEHV/6mJc=; b=h6+hoLxWgBRDpSTcL1r34/HBfsKdo7+wV6LI7nmIOfpj9kuM/mPoUlD0XLKV6FU6kF/bV+ glVN7T6bY2bASAJc+Y3fV9DVu4haZ1bpcFePtFjPUaDsxvJOed6cs2F2Y0/pyG1zXFGyDB raCsy3DdWYeOLeGzVj+26XIxKIMmLtA= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-269-I8ywql87Nv2cbPvz5nqjtg-1; Thu, 02 Sep 2021 03:28:45 -0400 X-MC-Unique: I8ywql87Nv2cbPvz5nqjtg-1 Received: by mail-wm1-f69.google.com with SMTP id r125-20020a1c2b830000b0290197a4be97b7so357239wmr.9 for ; Thu, 02 Sep 2021 00:28:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=bWmLpJjiGr7OPwqTTslMad67D5ZXIJqk/nCEHV/6mJc=; b=TzKdC6BdR3zWDgi4VueA76tmcyRuSk3VzOQ6menGFnY8+9OgTebKIQSsnXWOI5OPn+ Lonm57ryG1qFDF8Kl8mABWfqrEI/LXz2Yuzb1B/sHuzFJgqTQ01ViUOE0hIP13s72yKp ByW993JGlBMjkaMq0DaGEF6Uca51m+ujdJhYxIwxMZxo8mTzPghtkgC5SGohstVONlUq CD4OAi24KDX8LDqHTZNkW0ueF6nWHmyCgMC+IWv5Ly6G6rUnV2iqHdHWDEaSYzsDa2qJ Pf6sI4Cu8CfF+8RsZ1TPi/LmXn+e9nKrIQZeIVu2eSrghWiRClI0ceILs8N53idxliKs MBNw== X-Gm-Message-State: AOAM532P0FNzntXIe8gPTsZSzLoqI3lH+riILvIvcL2yvsRXKLYAHIcZ QjicAvKZjZ5YH1A0XKD0A3i0mlV5EevcvOCEXZzbkfd1VoW70g6z6WwZqpzkTcUnNmss/xifU8O EfE5LwCxU1mI= X-Received: by 2002:a05:600c:3641:: with SMTP id y1mr1668603wmq.181.1630567724306; Thu, 02 Sep 2021 00:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIOi+cTmhCifgWh9iVHFhrgRJpAHgEmMTgWMaiCle472LHiZLKPX+umcbB1iWehCf4YtMW6A== X-Received: by 2002:a05:600c:3641:: with SMTP id y1mr1668588wmq.181.1630567724125; Thu, 02 Sep 2021 00:28:44 -0700 (PDT) Received: from [192.168.3.132] (p5b0c60bd.dip0.t-ipconnect.de. [91.12.96.189]) by smtp.gmail.com with ESMTPSA id d8sm1030403wrv.20.2021.09.02.00.28.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Sep 2021 00:28:43 -0700 (PDT) To: Peter Xu , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , Yang Shi , Miaohe Lin , Hugh Dickins , Mike Rapoport , Andrea Arcangeli , "Kirill A . Shutemov" , Jerome Glisse , Alistair Popple References: <20210901205622.6935-1-peterx@redhat.com> <20210901205722.7328-1-peterx@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 4/5] mm: Introduce zap_details.zap_flags Message-ID: <5f3aa3fa-e877-02d1-8721-debbe688e7af@redhat.com> Date: Thu, 2 Sep 2021 09:28:42 +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: <20210901205722.7328-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 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h6+hoLxW; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf09.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 14C913000103 X-Stat-Signature: aaphyibyos13hfxqt1p95y4wagokhi8m X-HE-Tag: 1630567728-263963 Content-Transfer-Encoding: quoted-printable 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 01.09.21 22:57, Peter Xu wrote: > Instead of trying to introduce one variable for every new zap_details f= ields, > let's introduce a flag so that it can start to encode true/false inform= ations. >=20 > Let's start to use this flag first to clean up the only check_mapping v= ariable. > Firstly, the name "check_mapping" implies this is a "boolean", but actu= ally it > stores the mapping inside, just in a way that it won't be set if we don= 't want > to check the mapping. >=20 > To make things clearer, introduce the 1st zap flag ZAP_FLAG_CHECK_MAPPI= NG, so > that we only check against the mapping if this bit set. At the same ti= me, we > can rename check_mapping into zap_mapping and set it always. >=20 > Since at it, introduce another helper zap_check_mapping_skip() and use = it in > zap_pte_range() properly. >=20 > Some old comments have been removed in zap_pte_range() because they're > duplicated, and since now we're with ZAP_FLAG_CHECK_MAPPING flag, it'll= be very > easy to grep this information by simply grepping the flag. >=20 > It'll also make life easier when we want to e.g. pass in zap_flags into= the > callers like unmap_mapping_pages() (instead of adding new booleans besi= des the > even_cows parameter). >=20 > Signed-off-by: Peter Xu > --- > include/linux/mm.h | 19 ++++++++++++++++++- > mm/memory.c | 34 ++++++++++------------------------ > 2 files changed, 28 insertions(+), 25 deletions(-) >=20 > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 69259229f090..fcbc1c4f8e8e 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1716,14 +1716,31 @@ static inline bool can_do_mlock(void) { return = false; } > extern int user_shm_lock(size_t, struct ucounts *); > extern void user_shm_unlock(size_t, struct ucounts *); > =20 > +/* Whether to check page->mapping when zapping */ > +#define ZAP_FLAG_CHECK_MAPPING BIT(0) So we want to go full way, like: typedef int __bitwise zap_flags_t; #define ZAP_FLAG_CHECK_MAPPING ((__force zap_flags_t)BIT(0)) > + > /* > * 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; > struct page *single_page; /* Locked page to be unmapped */ > + unsigned long zap_flags; Why call it "zap_*" if everything in the structure is related to=20 zapping? IOW, simply "mapping", "flags" would be good enough. > }; > =20 > +/* 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; > + > + if (!(details->zap_flags & ZAP_FLAG_CHECK_MAPPING)) > + return false; > + > + return details->zap_mapping !=3D page_rmapping(page); > +} I'm confused, why isn't "!details->zap_mapping" vs.=20 "details->zap_mapping" sufficient? I can see that you may need flags for=20 other purposes (next patch), but why do we need it here? Factoring it out into this helper is a nice cleanup, though. But I'd=20 just not introduce ZAP_FLAG_CHECK_MAPPING. --=20 Thanks, David / dhildenb