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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34D9DC2BD09 for ; Fri, 28 Jun 2024 17:05:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9116D6B008C; Fri, 28 Jun 2024 13:05:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 898C76B0095; Fri, 28 Jun 2024 13:05:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 711AE6B0096; Fri, 28 Jun 2024 13:05:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 507D66B008C for ; Fri, 28 Jun 2024 13:05:52 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C61501605FE for ; Fri, 28 Jun 2024 17:05:51 +0000 (UTC) X-FDA: 82280924502.04.67BA6D3 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by imf06.hostedemail.com (Postfix) with ESMTP id B520A180006 for ; Fri, 28 Jun 2024 17:05:49 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qGvRT4ZM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of jiaqiyan@google.com designates 209.85.221.44 as permitted sender) smtp.mailfrom=jiaqiyan@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719594334; a=rsa-sha256; cv=none; b=6iOA6MxwvQNs43tXR3GXMdrjYgCLOCobopfA5LTY1X1tgrH/L/wA2H7hi5owbcg3et9Fb+ WRgRwqyFzH/lum9EPaFsdPHSIZIk1guBvCIJZob5gX0inp/3suac5cO3hnZwxvRFh60/BD lDBF6MwdKX6eQZ4JsO2HSjDbbv+S9I0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qGvRT4ZM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of jiaqiyan@google.com designates 209.85.221.44 as permitted sender) smtp.mailfrom=jiaqiyan@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719594334; h=from:from:sender: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:dkim-signature; bh=7JMuJ9WrfogZq4ya34x07iwBb8XotRWBpir1ixYVjF4=; b=5DQ9gIb+dkChYFQBvoOLxOzgOUtUIdmkr+ojDhZnnflFufEw7bB9fZaKPG+EptBcSTjEUn HQTTyUVV8b9MWnX5c5t0WyjArgo9DTN2STmx3I1f+NYrPoPNjF8TN3cQGt1uGzn4cCt8Aa SoR5Lwt6xrqY3Jh48J9zvPCyRotNvtY= Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-366de090da9so461685f8f.1 for ; Fri, 28 Jun 2024 10:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719594348; x=1720199148; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7JMuJ9WrfogZq4ya34x07iwBb8XotRWBpir1ixYVjF4=; b=qGvRT4ZMvRUTmG3+EEvecT3zskTx+EAGT44QETFLPcLUg8xlZ2PVNSbsAvaV3t/D3w M17LHMBiD2IbIH6yio+xZTeVrBQ6vVVtm13knH2sFhwVs91nnUhosYIMFjZ5iGDpI/qD ouxThTvclBb/rQGGgxt4D0pW1J1cF24BdderKo8nxgGNldFyPZBdPliqFUm5iTavATzv vlmtwDKfB2nR54DPhI0JQnzgmkEzJn68KxgTFXHs3fX79OF+M0uBewuy76lIUaBiziDR +1RspWAbBjNjRGl9QQcu34xBqTSn2AGJk3DGDLMyYFdaj8YaYDBNky4DaB7uGUUyhAeK nSjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719594348; x=1720199148; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7JMuJ9WrfogZq4ya34x07iwBb8XotRWBpir1ixYVjF4=; b=hFV0fLcLTdoqtsWUE8/Lo1S4UtQcT0AGz/MDcrXiTjOvP+qZ2v6L8wZG/zHU4+1fG3 lJuPyYpNCLCzxYKbTAacoqhi4nsAJX0Pw4P1Urp9u+5DWiAxqjftfLNUsP8f7qIvNME1 mQLY9/GHROROP56RV3WEwmXKjTkgHSGfZQ7uOg05yMO718xa3q/+r0TktQrR6hC0ueNF p2D9YHkRDKV3jYKVSx+0bhBP/P40+W/S2V2SgtRoAGbVuRVYU29zLR9YdFvVVOgBgVgV TVhI2AS0rX/y3SrJxtNn8Wk2+5q6Le9BPVKm/S9mU/QYR3Qi/hByCsHCuR23DIEMZMeX gpkw== X-Forwarded-Encrypted: i=1; AJvYcCWkAoDwguT0KykO80xHhGtmmEPCerS8rYVN0szHvYkQiVW1gbMuTDyd1QLs6bgsSUZ2DiFcfB3qi/167yfb82ySpCU= X-Gm-Message-State: AOJu0YyNU+ez181M/59u1t28Zp06kf641KnJQLl8vtgkUfqIk9mQQgVK xU0y/gH+kTykJbn9u/g9wRuwJxyHCNq7atb+85PjbQ0uR3KJElPJ4dS4Ei2vftHxE6WRnPdgmvB VNBo9rxb/pWIwWcGWu8h/FsHsgV2t3yZ6bWon X-Google-Smtp-Source: AGHT+IEtGSMHTUSiuH4qecwoSYwDClax9Ks0+jknR4nUZCpYb5T2i0hSeDcSxau3zWfrEW3QMVrBGqKb9lvnYn+w+Tg= X-Received: by 2002:adf:e706:0:b0:367:3ce2:31e2 with SMTP id ffacd0b85a97d-3673ce2329dmr4096604f8f.23.1719594347672; Fri, 28 Jun 2024 10:05:47 -0700 (PDT) MIME-Version: 1.0 References: <20240626050818.2277273-1-jiaqiyan@google.com> <20240626050818.2277273-3-jiaqiyan@google.com> In-Reply-To: From: Jiaqi Yan Date: Fri, 28 Jun 2024 10:05:34 -0700 Message-ID: Subject: Re: [PATCH v6 2/4] mm/memory-failure: userspace controls soft-offlining pages To: David Rientjes Cc: nao.horiguchi@gmail.com, linmiaohe@huawei.com, jane.chu@oracle.com, rdunlap@infradead.org, ioworker0@gmail.com, muchun.song@linux.dev, akpm@linux-foundation.org, shuah@kernel.org, corbet@lwn.net, osalvador@suse.de, duenwen@google.com, fvdl@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B520A180006 X-Stat-Signature: hibu5mocxxqe6kyswdcym5xm61j9faob X-Rspam-User: X-HE-Tag: 1719594349-976048 X-HE-Meta: U2FsdGVkX1/xxsModWLSewsaONJbf09yh60YQ93lmgrkK2Tf8RalLwbzI0/5jrZAOu4xYH9FQFYJMF4z2Kpxc7bp6SZX4fPbgYs8kplenuq74Yruk/nb2XR189J2QHOKf3Vb7/BenlsHXiMmvP9s0nhA/b0MZUIT76LE19f0cCQutC8TcIuHR7GPwME0sloQNwFbxW7Cj2O7cj12tktRW4yyHj0YN2DGMhn6otlyQOQbgZDJaU9AHzg99EYqP3wb36APg079ze1iMX3DcITuDGQPlhnMRKKV1WAbKGdBcQcWahYHfqutJ2r5IALSImeq4u/ixNffIkHyMjrStba88fX3FDQFL7DF9hgVi/BztciaMi9etQ+g2ookHnvdk6FQNtNx8+AXUaJsZOVkEajvDpIRqCowgroG40EvZ/up/6vn9AD3tCEw1IT5BA0ZzMZqf4m4NNwDwhVihs5IcOLyA0u3EiC/i8bUy9Ak7XhMERplXEbmeeKHu68P4Lb+lqQleM4/vlTKdeG+zTEcwDUWXKWPuxFtGtFqH9nh7wHYth1x1MDeK2OHS5zyTztwe4NPoNj310QLafrkAjMFYPW9Aseaqq+F3nZip4Hqjl7+xCkbkweF7M4ITw72odtY4MXQdCJZ33t2BQisMmX4iX53/zok5UG2+LhMuh29EQeTkMXLA0syZ54VkTkmdjF/V+DkGQZnfyEcF7IBUqS9JjRiW9F7cmrqiOiUHdb9eTECL5kd8AJIkfGvU/NFI/Cup/OlA+ezH/fkQ7b/HH81EobgiAi2zSU4wj1y539ufOy0JNZSqSgzqsAdzaKTQtahoapA/GVtyApj6cShNEsqvolrW3Fo6PyiPhcc0KGGoBDwLmtYi6smrzwu43HZt+YdslgiQhv/UZIRkdB15lHeLVnswQVNiZ5jCrhm1mbM9UiKcyHLyNb//+bokC83usJT4+qv6kow+WTipbB4hl263XQ c4dquPLQ gO3QSzYcG9dpPQirOZFRE4cKFDxuQ9OUs70PDH+8PwdDD/ikiqvc7tyXWewNP6VLHpTipJvISVU285Rt/D1PxkWrjVINDpkHF0RXgCen0np1/pa//HGJHIlPqe1RrxwouqoBcx8wRMUvC9aDtrzE+HbzgLTl1sJJ3p5jtsRre7821uhmV1glu/5ssIFilwbgcGyHfaUSwIsGkl0AH1olsZcSTn/MJirqxtzVtQVGGokdBP157j6uciSnS1usnSles/ZXHlIYN/nJK2Jw= 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: List-Subscribe: List-Unsubscribe: On Thu, Jun 27, 2024 at 8:27=E2=80=AFPM David Rientjes wrote: > > On Wed, 26 Jun 2024, Jiaqi Yan wrote: > > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > > index 6f5ac334efba..1559e773537f 100644 > > --- a/mm/memory-failure.c > > +++ b/mm/memory-failure.c > > @@ -68,6 +68,8 @@ static int sysctl_memory_failure_early_kill __read_mo= stly; > > > > static int sysctl_memory_failure_recovery __read_mostly =3D 1; > > > > +static int sysctl_enable_soft_offline __read_mostly =3D 1; > > + > > atomic_long_t num_poisoned_pages __read_mostly =3D ATOMIC_LONG_INIT(0)= ; > > > > static bool hw_memory_failure __read_mostly =3D false; > > @@ -141,6 +143,15 @@ static struct ctl_table memory_failure_table[] =3D= { > > .extra1 =3D SYSCTL_ZERO, > > .extra2 =3D SYSCTL_ONE, > > }, > > + { > > + .procname =3D "enable_soft_offline", > > + .data =3D &sysctl_enable_soft_offline, > > + .maxlen =3D sizeof(sysctl_enable_soft_offline), > > + .mode =3D 0644, > > + .proc_handler =3D proc_dointvec_minmax, > > + .extra1 =3D SYSCTL_ZERO, > > + .extra2 =3D SYSCTL_ONE, > > + } > > }; > > > > /* > > @@ -2749,8 +2760,9 @@ static int soft_offline_in_use_page(struct page *= page) > > * @pfn: pfn to soft-offline > > * @flags: flags. Same as memory_failure(). > > * > > - * Returns 0 on success > > - * -EOPNOTSUPP for hwpoison_filter() filtered the error event > > + * Returns 0 on success, > > + * -EOPNOTSUPP for hwpoison_filter() filtered the error event,= or > > + * disabled by /proc/sys/vm/enable_soft_offline, > > * < 0 otherwise negated errno. > > * > > * Soft offline a page, by migration or invalidation, > > @@ -2786,6 +2798,13 @@ int soft_offline_page(unsigned long pfn, int fla= gs) > > return -EIO; > > } > > > > + if (!sysctl_enable_soft_offline) { > > + pr_info_once("%#lx: disabled by /proc/sys/vm/enable_soft_= offline\n", > > + pfn); > > Any strong reason to include the pfn in the log message? > > I'm concerned about allowing a user to deduce the physical mapping for an= y > arbitrary page since this is possible to do through MADV_SOFT_OFFLINE and > I don't think that it adds value, especially if this is pr_info_once(). Agreed printing pfn value doesn't add value. Will get rid of it in v7. > > If we remove the pfn, feel free to add > > Acked-by: David Rientjes Thanks David! > > > + put_ref_page(pfn, flags); > > + return -EOPNOTSUPP; > > + } > > + > > mutex_lock(&mf_mutex); > > > > if (PageHWPoison(page)) { > > -- > > 2.45.2.741.gdbec12cfda-goog > > > >