Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4290734pxb; Mon, 27 Sep 2021 13:40:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRaj5Dw8/CXfMmeW2I5/AhwmM9VbK6iCbTErw6bHdGWSrTDE4Z99PUkCrYAOPk6VCQn7UJ X-Received: by 2002:a17:906:7208:: with SMTP id m8mr2448300ejk.82.1632775209250; Mon, 27 Sep 2021 13:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632775209; cv=none; d=google.com; s=arc-20160816; b=cvTEdmDEw+0UdTeSlivX1amMtsgEnynfMeViWuaJmK4JkcSYWZ6rnX50NL2JCD/t7d SdkbIVxlT0FTBwIr5jrvrulVoj9vaCNRs/A8VNPATKj1Ro8OMqYKF7hV9yjKY8Pvvktr RSeoxn1SAxy1ri4uvIbU3JDGkTuse+IDZtKsOTKjN/fmO9XU/y0Dsd+yNysGMzF8Vsgd ZCjRqBrf/eLUTfLI2yk9s9vr3yWBBZTPlfzAqw1uwtGp6SriE0xpgnGjOSuWz/briq57 +JD7TbfXxZPwvdIxqx7y6xidIVqCUmBd31tzYuwB2YcE0LKStc8HEgEIqMg3qjbJ/ltw bTIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=KwntqUtVsNq0eUFSV1/o/nRAcymM++4zNUK+VLfzUDE=; b=PXqh3Z9slktwK5IDv/ubSCtDX217tHkvUSIRK2GExNuGGybjEtE572ooSawpyQuXZh JIWv8hQ/LfVG8OEhLzoz2djtjbhggaLw88GvJfBtRP1dRgvKJstxTqfoEJFy6VGFIRbX EGTHe1hE/LbjnZFhWAi1C0MWuH3Bxgbe6mfGDXYjGiUNcM6mXL6EeMOKkFFLkSHOgcxH IgjXPlU7l2hDnbC4dMMOFL8bZnlFovtxtWUY+gex7CD20oDF889OMa28z2qZ8booVvfi R9VQdcxrRKAZSsfpUMkDQcjawAVMr26zLU5g35BfEC3tH2z3k6t9i4/s8osCsdUQFDhB paKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qwIUO+3o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si1473768edz.119.2021.09.27.13.39.45; Mon, 27 Sep 2021 13:40:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qwIUO+3o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236414AbhI0UiB (ORCPT + 99 others); Mon, 27 Sep 2021 16:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235865AbhI0UiB (ORCPT ); Mon, 27 Sep 2021 16:38:01 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12340C061575 for ; Mon, 27 Sep 2021 13:36:23 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id kn18so362827pjb.5 for ; Mon, 27 Sep 2021 13:36:23 -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=KwntqUtVsNq0eUFSV1/o/nRAcymM++4zNUK+VLfzUDE=; b=qwIUO+3oC6laZ/gJKGvYxv3lflTfsHoCZozQwFOCCG93M44AOCtYwoSK4+BlxN6uMM xXIRst5Jp1b1D8GLGaK3cgg7QCm8wwMGodWCT3Yzt0Hb2ZWkJJT7jIWqZ/eBpR6P6oPs Ho3XAgMKKCBgJzgylh3jmiM5/KdLQdltQcC/ntQwQe8mPYrQ+iD9NWtQO94KwnTHmbcT 7ZMTHwRVTvo2Quxwo/TTRWC0MatJPUwxXLv4szstzuXPvM3ApWzeEiUHlgJXIR1tmX1u B/+dg7r7cJ44YMKuJ8Ct0BdcdzI1qAy/4DHMqaETzhldsUmSe91/m+Y+IbkStrwJZ2/z RHdg== 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=KwntqUtVsNq0eUFSV1/o/nRAcymM++4zNUK+VLfzUDE=; b=QQ2ThxeeEcDTRknakQU6ztYWjldiHem2wc3Q52aNXCgP84qzkSJ7niUP53LP+ewJab sE5c0dC5ayzc+ldmBnccaazJOpd7XWAtOSDBHpZ0CoQZSiJi+YQkLHbJpwbe1VxzKJ1g mG9lV7zzVJ5h7LtoofsWMD3BAsXZd1sPW01mpSVgy4ZQ505Fl0KblCQqzFaTElRlE4rN klAHaNI8Lre+aBjmQkzK0DdL6k6ugtH3g4WOARcWb3auEiyk1AAN8a9dBYdZGhu2Ckub wgEWCUQaXE4lo06Ulv09rVf3hvasdJR8GShq7ckI3QzKYO/lDYSm0FNOA2ysXn9bh/2V XPTQ== X-Gm-Message-State: AOAM532+qZt984dRfMM6/bGxyZujhoTi/5deHGvHptSNwyYkMWiGE7Bz +ygyCPQihwx+O9oMPUXt5qQ= X-Received: by 2002:a17:90a:17e1:: with SMTP id q88mr1113946pja.99.1632774982476; Mon, 27 Sep 2021 13:36:22 -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 y24sm10396984pfo.69.2021.09.27.13.36.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Sep 2021 13:36: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: <20210927121449.kac5g25aejbwvylf@box> Date: Mon, 27 Sep 2021 13:36:20 -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: References: <20210926161259.238054-1-namit@vmware.com> <20210926161259.238054-5-namit@vmware.com> <20210927093103.g3cszw75gfctwtzk@box.shutemov.name> <48D4E700-0005-46D4-8EAA-B839D8449C66@gmail.com> <20210927121449.kac5g25aejbwvylf@box> To: "Kirill A. Shutemov" X-Mailer: Apple Mail (2.3654.120.0.1.13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Sep 27, 2021, at 5:14 AM, Kirill A. Shutemov = wrote: >=20 > On Mon, Sep 27, 2021 at 03:31:21AM -0700, Nadav Amit wrote: >>=20 >>=20 >>> 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 [ snip ] >>> MADV_SOFT_OFFLINE+1 smells bad. >>=20 >> I can set another constant instead and let the compiler shout if = anything >> outside the array is initialized. >=20 > I would rather introduce a function that would return struct = madvise_info > for a given behavior. The function would have a switch inside. The = default: > may have BUILD_BUG() or something. Sounds better than my solution. I will do so.=