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 596643B42EC 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-48436370540so840100f8f.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=T+3+Iu8qae2nbbKO4kBQxPs+at34xqRJ97nNqL0dXNu01XVwovJD+4hFHbL9Xm2JzH xxqeo19dlVf8zrDJoH711XJ11XN3bCXakUj6wTBR2yF8BchK98+myromrFnlcpkNrOfg OerkgRqPSQgP1gBgo8QA70vGRK9jTk7NKORE8ugrotIAnR8APtT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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-kernel@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. > ?