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 84756C433EF for ; Thu, 7 Jul 2022 16:20:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F4986B0072; Thu, 7 Jul 2022 12:20:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A35E6B0073; Thu, 7 Jul 2022 12:20:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 892986B0074; Thu, 7 Jul 2022 12:20:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7A3696B0072 for ; Thu, 7 Jul 2022 12:20:34 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5278D205E4 for ; Thu, 7 Jul 2022 16:20:34 +0000 (UTC) X-FDA: 79660816788.01.D89A78F Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) by imf06.hostedemail.com (Postfix) with ESMTP id F06EC18000F for ; Thu, 7 Jul 2022 16:20:33 +0000 (UTC) Received: by mail-vs1-f49.google.com with SMTP id j65so1472355vsc.3 for ; Thu, 07 Jul 2022 09:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ci6aP7nKVQUaHARVmSRnYm57qnA3hBbkbfQkbvG0XxM=; b=bn2LAVeJrnwPGUJTR23aVQd2z1NTOuHTvpU/tYSYxdlwQuROcEQ3mFWTjFuR/eT9bz kOmuNckX3qdC7gTX86kUSMLc6ba6opfm5k4s8kIQPVFordq1Y8xDfPcR/yIE4vdjn1di nsxdWsPC0KBppiVaq34zd4k25zNJtoGIi/zZlu+PcrYCHpnMeLxpFHYFmM7BTP/0DFl5 Wef945ienMtpNZsusurRYwMMfHESj7SYZ2z1J1QHb2k7ijZGQmdiT8o0IHVAFaBQtbM5 AcZCaF1YddU4OgOsUBFxmCL9FGzfb7czqj4kPJ4MD/nQ1VJmCg9WZcUZrTDbkX4qf3+F 4b8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ci6aP7nKVQUaHARVmSRnYm57qnA3hBbkbfQkbvG0XxM=; b=O4ELnlLQmR2MbrvR7eALSlJSjXW4iZSAAF4IhcwJbnDhcNlbDEAtbHmMn84yB/5GpY bicqPWt5/ufexMKlmiOklS0nYvENh7IJHA/zuMWGSRfyknLcPtaZoJl2b4AY5AJcGNOS OW0XdhIkoylMNB+6y/Jgq1Nh1D+YWSKu8GUmyFFPPZ7t+B7kZPXxGnMJ6roQHEYzgATt ezxgk0AEWL6REs5LvtdGvIqQ0d4GzVnk6RlWtBUTv91/z/UX6VxRiPFjdUeThaJtTpqf rus2n9C14x5ERFgvHchXK6KW7TV+kCDGBwHhKXOdhWeBiQ41c0B9mztaaltALRDinNHW LS6Q== X-Gm-Message-State: AJIora/KS0fTHvD/UnVfrUBO9zaT2nKrUOQi2oPxf5Er7njtxXHJb/Kr L5ZQs6Iwkslqa8bcO6pYDRL26zImzRZ5aHf5SKY= X-Google-Smtp-Source: AGRyM1vEEck/CSTfqPPPCywcusjE/F0df+gWYrSoMQDaMK9O8h1v3u4YxUY9WEwcXcYOwfz537RsgK/t4A36exmbZYA= X-Received: by 2002:a67:1945:0:b0:355:ab65:9db3 with SMTP id 66-20020a671945000000b00355ab659db3mr27849908vsz.22.1657210833074; Thu, 07 Jul 2022 09:20:33 -0700 (PDT) MIME-Version: 1.0 References: <20220706155848.4939-1-laoar.shao@gmail.com> <20220706155848.4939-2-laoar.shao@gmail.com> <20220707000721.dtl356trspb23ctp@google.com> In-Reply-To: From: Yafang Shao Date: Fri, 8 Jul 2022 00:19:56 +0800 Message-ID: Subject: Re: [PATCH bpf-next v2 1/2] bpf: Make non-preallocated allocation low priority To: Alexei Starovoitov Cc: Shakeel Butt , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin Lau , Song Liu , Yonghong Song , john fastabend , KP Singh , Quentin Monnet , Roman Gushchin , Hao Luo , bpf , Linux MM Content-Type: text/plain; charset="UTF-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657210834; 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=Ci6aP7nKVQUaHARVmSRnYm57qnA3hBbkbfQkbvG0XxM=; b=n/qG1cAKB+CL2kdCZSCJukD0onUju4He83S8yMThlApM7adRpg04BvxuZN2E7pu9M3Bamp elxRNLqcGwyGuerEKO9s6C2YoKkjESJTnfo76txFsRt263oEhmJA77BLb9uH+98uhJivm9 +RUIvau334zsxwDLxN+Lj67mIDTPrmc= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bn2LAVeJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.217.49 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657210834; a=rsa-sha256; cv=none; b=JxM1hFvPZpTIrVLCAzolJC6TxfUnXCYoWIFj63JQ3D/IO05OmeF3rnc9Wd7PEmf0zCV3y+ 3F+sLlbtx02y+VLAJQCrv60n2z4BU9CUhKZGNHqyDETFcikQlhCBR0cAcMtbPX2IPld2zR G1MHoe0pD4mLTgg0XoIcYfX/uHP1dSY= X-Rspam-User: X-Rspamd-Server: rspam07 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bn2LAVeJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.217.49 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com X-Stat-Signature: p9rocpycb971xckj1p915u3e9jx3oq4f X-Rspamd-Queue-Id: F06EC18000F X-HE-Tag: 1657210833-135865 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 Thu, Jul 7, 2022 at 11:44 PM Alexei Starovoitov wrote: > > On Thu, Jul 7, 2022 at 3:28 AM Yafang Shao wrote: > > > > On Thu, Jul 7, 2022 at 8:07 AM Shakeel Butt wrote: > > > > > > On Wed, Jul 06, 2022 at 03:58:47PM +0000, Yafang Shao wrote: > > > > GFP_ATOMIC doesn't cooperate well with memcg pressure so far, especially > > > > if we allocate too much GFP_ATOMIC memory. For example, when we set the > > > > memcg limit to limit a non-preallocated bpf memory, the GFP_ATOMIC can > > > > easily break the memcg limit by force charge. So it is very dangerous to > > > > use GFP_ATOMIC in non-preallocated case. One way to make it safe is to > > > > remove __GFP_HIGH from GFP_ATOMIC, IOW, use (__GFP_ATOMIC | > > > > __GFP_KSWAPD_RECLAIM) instead, then it will be limited if we allocate > > > > too much memory. > > > > > > Please use GFP_NOWAIT instead of (__GFP_ATOMIC | __GFP_KSWAPD_RECLAIM). > > > There is already a plan to completely remove __GFP_ATOMIC and mm-tree > > > already have a patch for that. > > > > > > > After reading the discussion[1], it looks good to me to use GFP_NOWAIT > > instead. I will update it. > > Should we use GFP_ATOMIC | __GFP_NOMEMALLOC instead > to align with its usage in the networking stack? GFP_ATOMIC | __GFP_NOMEMALLOC will continue to break the memcg limit, so we have to modify the try_charge_memcg() code to make sure __GFP_NOMEMALLOC takes precedence over the __GFP_HIGH flag, IOW, if both of them are set we won't allow it to break memcg limit. That will need more verification. -- Regards Yafang