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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC279C433EF for ; Mon, 27 Sep 2021 10:31:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0947761002 for ; Mon, 27 Sep 2021 10:31:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0947761002 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9B5DB6B0071; Mon, 27 Sep 2021 06:31:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 965A76B0072; Mon, 27 Sep 2021 06:31:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82D8D900002; Mon, 27 Sep 2021 06:31:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 732856B0071 for ; Mon, 27 Sep 2021 06:31:25 -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 184081808724B for ; Mon, 27 Sep 2021 10:31:25 +0000 (UTC) X-FDA: 78632986530.34.C6D8141 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf13.hostedemail.com (Postfix) with ESMTP id BBF6710328EA for ; Mon, 27 Sep 2021 10:31:24 +0000 (UTC) Received: by mail-pf1-f175.google.com with SMTP id k26so10810681pfi.5 for ; Mon, 27 Sep 2021 03:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HtxhxA6meUImIIHC4/23ng+l1TP2cniMkNWzkjyF/iA=; b=LXx4yFUpzLbI0HXR9Y5FD3o4P9EHoA5w7yA1gJrz7Sb2LuHe7j+VbBuJ4L/mNUzara 6TKYitNGrdTgA8XVyI3OtZaFp5W4EvnPKGtlvcGel3fIs7tXYiwh1ENwdoNp2f+q0864 0TbLT/H0PkbVmAT+5y2kDErd4wxxZzs/YCrrwyhODHvl8c6UxH6OfAMJ5SLKaQOEewbH +ECtGJVLKZ9irspFvEsxlwDLrkpKJMjHVhp8x99MhmqvKp//GnwRrsaNdSJ4BSV3h+b+ 7SermQiGsMB2FdMxO377pJNwwGXQAD+00A/v3tpJ573IfKhaT8jV6svrFEkh8LzOmT/c 6ggQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HtxhxA6meUImIIHC4/23ng+l1TP2cniMkNWzkjyF/iA=; b=HqQxpMeLHwSnrr3/5ORI/Vr1GQlANVPkrWQeqLCuI4KAu8rIkzjb+eFGSwU0xLPUGK UIGiHrWgfRawd+1jg6RPWm1i/qo2Tnnnxnb19xsxfF5hOToB1ArwYiPnEDNb5Jv1aYr4 iu/uUVPX43aETy+SwbXdc/MXm+ERFGC9kUgeTTijHk7x4gHT3TIQ1yxoxstCiWMNvebR do2qvGNV4pnPYk5tFehLR5UEcGVbmJ/vCZBPm4FUFmhRzZ0qgWi5E21TOxBn2XkORssZ 81W2cNMPCtKwLm2CTaRRvD7gs+loUc9NNoQlLLOxXs2nSNNe+VwT6nLeZ++FjYNF3vEf EvXA== X-Gm-Message-State: AOAM531GfQOQCHveMEwZVJ8vVZnSmkuijMnwCNEIBJ7+JXeRyAs4iYOB cxQzRLodGNR0K1pyF6T+nMg= X-Google-Smtp-Source: ABdhPJxEgiJ/+ilfc4k4aCeWursLDLsRDFPSWG35UzaJxfmw7a9IDWSFSr9sAjUzjSkdifNyn5ioBQ== X-Received: by 2002:a63:8541:: with SMTP id u62mr15840859pgd.308.1632738683465; Mon, 27 Sep 2021 03:31:23 -0700 (PDT) Received: from smtpclient.apple (c-24-6-216-183.hsd1.ca.comcast.net. [24.6.216.183]) by smtp.gmail.com with ESMTPSA id b23sm16959276pfi.135.2021.09.27.03.31.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Sep 2021 03:31:22 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [RFC PATCH 4/8] mm/madvise: define madvise behavior in a struct From: Nadav Amit In-Reply-To: <20210927093103.g3cszw75gfctwtzk@box.shutemov.name> Date: Mon, 27 Sep 2021 03:31:21 -0700 Cc: Andrew Morton , Linux-MM , Linux Kernel Mailing List , Peter Xu , Andrea Arcangeli , Minchan Kim , Colin Cross , Suren Baghdasarya , Mike Rapoport Content-Transfer-Encoding: quoted-printable Message-Id: <48D4E700-0005-46D4-8EAA-B839D8449C66@gmail.com> References: <20210926161259.238054-1-namit@vmware.com> <20210926161259.238054-5-namit@vmware.com> <20210927093103.g3cszw75gfctwtzk@box.shutemov.name> To: "Kirill A. Shutemov" X-Mailer: Apple Mail (2.3654.120.0.1.13) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=LXx4yFUp; spf=pass (imf13.hostedemail.com: domain of nadav.amit@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=nadav.amit@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BBF6710328EA X-Stat-Signature: iish4c3rc66ecrnaqiqqe1x8pcbmwf6f X-HE-Tag: 1632738684-246135 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 Sep 27, 2021, at 2:31 AM, Kirill A. Shutemov = wrote: >=20 > On Sun, Sep 26, 2021 at 09:12:55AM -0700, Nadav Amit wrote: >> From: Nadav Amit >>=20 >> The different behaviors of madvise are different in several ways, = which >> are distributed across several functions. Use the design pattern from >> iouring in order to define the actions that are required for each >> behavior. >>=20 >> The next patches will get rid of old helper functions that are = modified >> in this patch and the redundant use of array_index_nospec(). The next >> patches will add more actions for each leaf into the new struct. >>=20 >> No functional change is intended. >>=20 >> Cc: Andrea Arcangeli >> Cc: Andrew Morton >> Cc: Minchan Kim >> Cc: Colin Cross >> Cc: Suren Baghdasarya >> Cc: Mike Rapoport >> Signed-off-by: Nadav Amit >> --- >> mm/madvise.c | 168 = +++++++++++++++++++++++++++++++++------------------ >> 1 file changed, 109 insertions(+), 59 deletions(-) >>=20 >> diff --git a/mm/madvise.c b/mm/madvise.c >> index 17e39c70704b..127507c71ba9 100644 >> --- a/mm/madvise.c >> +++ b/mm/madvise.c >> @@ -29,6 +29,7 @@ >> #include >> #include >> #include >> +#include >>=20 >> #include >>=20 >> @@ -39,6 +40,101 @@ struct madvise_walk_private { >> bool pageout; >> }; >>=20 >> +struct madvise_info { >> + u8 behavior_valid: 1; >> + u8 process_behavior_valid: 1; >> + u8 need_mmap_read_only: 1; >> +}; >> + >> +static const struct madvise_info madvise_info[MADV_SOFT_OFFLINE+1] =3D= { >=20 > MADV_SOFT_OFFLINE+1 smells bad. I can set another constant instead and let the compiler shout if = anything outside the array is initialized. >=20 > And I don't like the change in general. Given that MADV_SOFT_OFFLINE = is > 101, the array will be mostly empty. Seriously, these is less than 128B - two cachelines. Perhaps they should be aligned. But this whole change should have no effect on code/data = size. >=20 > I donno. I don't see any improvement with the patch. But maybe it's = only me. The following patches make it clearer when TLBs flushes are batched and when mmap_lock is not taken (which is by the way not clear from the = code). I could have added two more functions for that and it would have taken me less time. I do not think the end result of having ~5 different functions to figure out the actions needed for each behavior would be as clear.=