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 04E79C433EF for ; Sat, 2 Jul 2022 04:23:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 673C36B0071; Sat, 2 Jul 2022 00:23:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 623BA6B0073; Sat, 2 Jul 2022 00:23:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 513956B0074; Sat, 2 Jul 2022 00:23:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 400556B0071 for ; Sat, 2 Jul 2022 00:23:29 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0ED1AD61 for ; Sat, 2 Jul 2022 04:23:29 +0000 (UTC) X-FDA: 79640865738.08.75071EC Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf28.hostedemail.com (Postfix) with ESMTP id 8CDF9C003D for ; Sat, 2 Jul 2022 04:23:28 +0000 (UTC) Date: Fri, 1 Jul 2022 21:23:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1656735807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SzXNs70WHMtboWd+grqVTGNXmGyPHBV+9qhpjinuT/Q=; b=mN5Q7vRy1UUefFFp6lW21PTy22P2fZiejxINM5EGYmMxDGaz2xQU2S9Q0swwk6CnPVQ9en dh64+nloD6q+mdFeCMTdh+u5TesvZlzbgdqcFPsWglix4UcgfHjrrXAMTZzQZmUkmwMxtx hwypus3zirQNrFntcfhD/YAmuWIDp5s= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Yafang Shao Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin Lau , Song Liu , Yonghong Song , john fastabend , KP Singh , Quentin Monnet , Johannes Weiner , Michal Hocko , Shakeel Butt , songmuchun@bytedance.com, Andrew Morton , Christoph Lameter , penberg@kernel.org, David Rientjes , iamjoonsoo.kim@lge.com, Vlastimil Babka , Linux MM , bpf Subject: Re: [RFC PATCH bpf-next 00/10] bpf, mm: Recharge pages when reuse bpf map Message-ID: References: <20220619155032.32515-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656735808; a=rsa-sha256; cv=none; b=bq8WW4eaRb9gCeBLZkTHtLsNiXPbGFEEIQCPCGQu+Ipbm2klMOE4Wub79JnZ/r+TOY1ax0 8LUzoJzYnCL1+yP0xlIm6/zDdUciFk82L7t9MeP/S+3tYcM32F6UT9O9tfWog0N0RyidHi fe/rbVF7OSwBRgaiAXOmlTZyKfsXzjU= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mN5Q7vRy; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of roman.gushchin@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656735808; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SzXNs70WHMtboWd+grqVTGNXmGyPHBV+9qhpjinuT/Q=; b=EkCJ8AxEypS6b5mKfbhPuHZrCTUebvSGsKHzJxhEJGgb3mMmp1wkh1y+oqaD9JQP5/XhvO bLKjH5JJzn7mJcdooA5UGZbTeaSpGeQBb3JSryLamu4IOhsbQ1GlBCi5cZADzXml6kTY8j FfYZnDTPzps+GMrAhIPZRAI1k/8eeVw= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8CDF9C003D Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mN5Q7vRy; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf28.hostedemail.com: domain of roman.gushchin@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev X-Rspam-User: X-Stat-Signature: 33sq48cuox14z56qotda6r69dedk3ih6 X-HE-Tag: 1656735808-996089 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 Sun, Jun 26, 2022 at 02:25:51PM +0800, Yafang Shao wrote: > > > htab->map.numa_node); > > > And then we'd better introduce an improvement for memcg, > > > + /* > > > + * Should wakeup async memcg reclaim first, > > > + * in case there will be no direct memcg reclaim for a long time. > > > + * We can either introduce async memcg reclaim > > > + * or modify kswapd to reclaim a specific memcg > > > + */ > > > + if (gfp_mask & __GFP_KSWAPD_RECLAIM) > > > + wake_up_async_memcg_reclaim(); > > > if (!gfpflags_allow_blocking(gfp_mask)) > > > goto nomem; > > > > Hm, I see. It might be an issue if there is no global memory pressure, right? > > Let me think what I can do here too. > > > > Right. It is not a good idea to expect a global memory reclaimer to do it. > Thanks for following up with it again. After thinking a bit more, I'm not sure if it's actually a good idea: there might be not much memory to reclaim except the memory consumed by the bpf map itself, so waking kswapd might be useless (and just consume cpu and drain batteries). What we need to do instead is to prevent bpf maps to meaningfully exceed memory.max, which is btw guaranteed by the cgroup API: memory.max is defined as a hard limit in docs. Your recent patch is actually doing this for hash maps, let's fix the rest of the bpf code. Thanks!