From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr2-f10.google.com (mail-wr2-f10.google.com [74.125.225.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5982747CA81 for ; Sat, 5 Sep 2026 11:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788607424; cv=none; b=TKQn9PDCfmxPsptR3YqdiuL1sOsX1W1U8kgmJmeP5AO8816hi4LBx7BNBZGsgFiFxnjShdn02YObVDrRdeg68DNUgniA59qyRIBPY5TiFv+WUOkkeZH2HSHKILaEam7kU//f2+0ULj5I0ymRrVYOTF3xsWNf7CjPGIZdGu46XnY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788607424; c=relaxed/simple; bh=46gfGGvOHamt2U6ZnlfStx9ZhBdMqYA1cvWxqwtmAYw=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=F6a89VIy1TxNqjRmAovsWieF6QWgwqo0yV9YlgOL+8ihPY5lPlHA+WITDuP5N1KmI1JE0ZER1kRk8NWrAt2ALLgIGaHItZdaNHkUVTxKggZwyB344prxbtbh91Sci+TcFvBZWDVPmgiCuTZ6hNgNlCjVlrFWmR9cqQV1asL//IA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q+A/z3ZD; arc=none smtp.client-ip=74.125.225.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q+A/z3ZD" Received: by mail-wr2-f10.google.com with SMTP id ffacd0b85a97d-48436370540so840101f8f.0 for ; Sat, 05 Sep 2026 04:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788607421; x=1789212221; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=OK8u0A1r5wARyyx+mQthY7pulPX5uc00KjP5Fs0Y5/U=; b=Q+A/z3ZDMSiXVgbRXO+zPozELZ6V3vjOQVVoRzZiHgeBqo4Om9xkt7FGx+oqDs2h2C hl0rmc2a8oze26WlFknREh1Jp308JbGotgds7kI0cFTSZakdxrDuY2KF9wu2+0KyIooF rGCBNfr8KG/9g+l9oeIiEfjhd1ZnNZf+ZR51fjd3zatku5Y4FJF0feRCEU/K/5eT+/Zh 9K7+hypVDH/AT8mQplZ5715R3Xg4ULsECVT4aKl/Y1xNNwuP7t6QJd8nCrIJCTkDYwV8 3h9zUnW9wNSvqNVkluVJ5poCvKR5l5uYy7Gr/YZJadR679rlgxN/XGoOPRTlgwNsvMwW y28g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788607421; x=1789212221; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OK8u0A1r5wARyyx+mQthY7pulPX5uc00KjP5Fs0Y5/U=; b=rnyuAFusK9TgRXlpKg1RIS2hZHEw+dXwiZV46irKVg9hhiGPctU63f7CqkOuHqNpLv nTNhMoig4DG7boHS9JQLrIGykSgNs9JuW1zn0ChCgdK9JZjxoQ49dWY0cPUKFI3tgB+r lz9Xu+XKk9x2pGQA6SSpyc+A6fF/k8558NtUlMyspc54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485:8c16:5ef9 with SMTP id ffacd0b85a97d-4858c166172mr8839779f8f.51.1788607421304; Sat, 05 Sep 2026 04:23:41 -0700 (PDT) Received: from localhost (nat-icclus-192-26-29-3.epfl.ch. [192.26.29.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-485958f1493sm1014293f8f.37.2026.09.05.04.23.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Sep 2026 04:23:40 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sat, 05 Sep 2026 13:23:39 +0200 Message-Id: Cc: "Roman Gushchin" , "JP Kobryn" , "Shakeel Butt" , "Andrii Nakryiko" , "Eduard Zingerman" , "Ihor Solodrai" , "Alexei Starovoitov" , "Daniel Borkmann" , "Martin KaFai Lau" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "Emil Tsalapatis" , "Shuah Khan" , "Barry Song" , "Geliang Tang" , , , , , "Hui Zhu" Subject: Re: [PATCH bpf-next v7 1/2] mm/bpf: Add bpf_proactive_reclaim kfunc From: "Kumar Kartikeya Dwivedi" To: "Andrew Morton" , "Hui Zhu" X-Mailer: aerc 0.21.0 References: <7d8b77dc99ffe99a7bef874a257472fdaaf07e1c.1788516769.git.zhuhui@kylinos.cn> <20260904110308.4473cde499e91aab14dbd5fc@linux-foundation.org> In-Reply-To: <20260904110308.4473cde499e91aab14dbd5fc@linux-foundation.org> On Fri Sep 4, 2026 at 8:03 PM CEST, Andrew Morton wrote: > On Fri, 4 Sep 2026 18:20:19 +0800 "Hui Zhu" wrote: > >> @@ -159,6 +160,74 @@ __bpf_kfunc void bpf_mem_cgroup_flush_stats(struct = mem_cgroup *memcg) >> mem_cgroup_flush_stats(memcg); >> } >> >> +/* >> + * Reclaim must not recurse: try_to_free_mem_cgroup_pages() overwrites >> + * current->reclaim_state, so a nested call would corrupt the outer >> + * reclaim state. Reclaim windows are marked with PF_MEMALLOC; >> + * reclaim_state is also checked because it is installed slightly >> + * before PF_MEMALLOC. >> + */ >> +static bool bpf_in_reclaim_context(void) >> +{ >> + return (current->flags & PF_MEMALLOC) || current->reclaim_state; >> +} >> + > > Would life improve if try_to_free_mem_cgroup_pages() didn't do that? > If try_to_free_mem_cgroup_pages() (or some variant of it) were to > permit nesting? > > rs =3D new_thing(current, &sc.reclaim_state); > ... > set_task_reclaim_state(current, rs); > My understanding is that given the current restrictions on where this kfunc= can be called, this is mostly a defensive and shouldn't be firing (?). Given th= at, we can probably revisit this when such reentrancy is necessary, even though= I doubt it would be the case in the future. It will at most be invoked from a= wq callback or a kthread, so should be fine. > ?