From patchwork Sun Feb 5 06:58:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13128980 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 0A77DC636CD for ; Sun, 5 Feb 2023 06:58:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 829346B0075; Sun, 5 Feb 2023 01:58:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B1186B0078; Sun, 5 Feb 2023 01:58:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 651EF6B007B; Sun, 5 Feb 2023 01:58:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 54D916B0075 for ; Sun, 5 Feb 2023 01:58:38 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2E0E780635 for ; Sun, 5 Feb 2023 06:58:38 +0000 (UTC) X-FDA: 80432335116.14.89B89AC Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf25.hostedemail.com (Postfix) with ESMTP id 61B1FA0006 for ; Sun, 5 Feb 2023 06:58:36 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Oy5xAL4a; spf=pass (imf25.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675580316; a=rsa-sha256; cv=none; b=CQO1rUWt36TQWWvhtpivpdVCegENzpa5kxa8Uyb/9jckV1ZhrsMM0tKH/w+aj9eQpzjlii /c09Z6po3l1ZlXvRrArNz4qTOJkCDhjn56rIRuy5EOSBmOMgSzzu1h/9vdWFCVn1XLXaCM cnCdEeLdYTd+Wzytn4s0EyiUhIf2bQo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Oy5xAL4a; spf=pass (imf25.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675580316; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rvT0LPmkis2rub1BPyeQPcuStniilZcgbmYKVTz7Hvo=; b=WyX1YMkYiPCocBid2nErl7hjVCpjItswRDWZhGgi74aaKSRv4VsEd2pyWYI04BPWEGDg0q UVxhXAhkDMOzU0WEejbfzrX+cTL6tLUNf7eyYfAQAKbHT4c1vnE66V91dxS1frPGF8Ysq0 vAKGuut4Vi7ZtBpTf5i0RJIFZiVNHcs= Received: by mail-pf1-f172.google.com with SMTP id 144so6367614pfv.11 for ; Sat, 04 Feb 2023 22:58:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rvT0LPmkis2rub1BPyeQPcuStniilZcgbmYKVTz7Hvo=; b=Oy5xAL4aXjTTwo6yYaI1NHOu5VWyI2xXvQE6gfQ6deE11ldVIy3ideM0a5D+DQHey0 1Ch7zNbFrAM2Mxq+adjEPGfyeb6rkTy+HItd92lPh8wBG4qwkyfkKPPwsViylhGza+2R 3m4jVEHwA/hpX7IsxmkeHZ7RjPVTU9InZBjXFDXeOK3Lrfwqm8SvHreAqgU64/YUAy6w Kv6b5gjZC6d3vw/2ds1OCOlSAyY5ByndnEwkG1T3n0AZC8BIy9hjKO7Ro6JNzD7+GWxY zNIqq6ubKqbPiTxzqG4R42z68sNVUDjUNaL3mxLmQ1F+t+JTCAnjxOizNdm3nk8hlzL6 0q2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rvT0LPmkis2rub1BPyeQPcuStniilZcgbmYKVTz7Hvo=; b=mfMspT4Itvvkdp1xezFq4ZY7Mc4PETsE/ALyn3KchzjNiJwvTwolwEsge2e9i7xJX9 QHcsC5pP1+515WS0JMJg8FwiWoGCAVJNffnUJ5Lt183yClgyNI+4271w5M+RdcuEm+PU tfnP57SJPMJB0x+7Qc484VWOGoO1bnfzofxYiVUEWEq9rAcyyU3p7q+Nm33+cmcFL1Sf aJ4XfEECCKpWDkgQuHaeVzuZuwJBa+iVK08E9EBtJuG34/qiGVH0XpaDERGabxvDicDP fC+ACxCYFKuzRDKEKC7XJj1OqxPBqta3ADJ3GLOm3R9cfmZXGm7rq757xiI2pjI5qDlJ YxmA== X-Gm-Message-State: AO0yUKW0LRsWP7WPkyNA29KzytUSHXF2HEmD5rBmAWjdHjFY58/RCR98 6Gu2kCjPGZzIMUD9GwUTb6U= X-Google-Smtp-Source: AK7set8rzEt0uEX1G54vHxZcUNYhAOhvPT5WYRO8loZlm4Skh+fcwGoowH1x0LGxykpYOtRuAaIVEA== X-Received: by 2002:a62:7bc4:0:b0:590:7126:4771 with SMTP id w187-20020a627bc4000000b0059071264771mr15626594pfc.1.1675580315371; Sat, 04 Feb 2023 22:58:35 -0800 (PST) Received: from vultr.guest ([2401:c080:1c02:6a5:5400:4ff:fe4b:6fe6]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm4596114pfv.184.2023.02.04.22.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 22:58:34 -0800 (PST) From: Yafang Shao To: tj@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, akpm@linux-foundation.org Cc: bpf@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Yafang Shao Subject: [PATCH bpf-next 3/5] bpf: introduce bpf_memcg_flags() Date: Sun, 5 Feb 2023 06:58:03 +0000 Message-Id: <20230205065805.19598-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230205065805.19598-1-laoar.shao@gmail.com> References: <20230205065805.19598-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 61B1FA0006 X-Rspamd-Server: rspam01 X-Stat-Signature: 4mbb7imcm3ucp3cu3eogrx6cdd7nhkts X-HE-Tag: 1675580316-521107 X-HE-Meta: U2FsdGVkX1+XKsLCEXtn6oRtq0UBEFlsVFRIOyZEaoM26P1uEXsOnpDVzOgHpYrvlh2XMHYVR0qniMWo8QdnYjWOdmvEJiWYyUGHRotVpneBQ9Y1Q25TsakAkbZpmadZQleGL7XOFiic/KDr3L5+Z3b2e29Q56MVSccCaXyafkIHbLFgf6fbpBYscYfT1z+ZtPQGxYVd968M+00LmhMU0mjz+TpgWruYSwXL8J73BnXMnBdgIyZGqeJCQDChXJ9zx+/ydK5iMQ2XJ0U/q2wr+q4KsMn5OnmXEIApYNKArM7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qA94pokNn5PsYX7THnKF+cKusgdbcQ1mo8rHvz3FDUElt8hSzoquj9acQgZyV10CmjOVzOl9dWIablLYw0G8P2cRZDrepjfFFVC2MIo36I/99YMJo5c25XuP8UELDufGZ3diC9VDlzrM0RXzCVTn7gQ0KMMhK/ay/UI1eisc4bpWU7r9YagD8IDn6IU2jL7I6Y+hiF1U5YNBu+cD2Uq2kQIfeuOZrUEqJeTlmMb7FoSQt7iHtNEw8IQHzNiM/GDepSs6gxgwh 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: This new helper will be used in both bpf prog and bpf map. Signed-off-by: Yafang Shao --- include/linux/bpf.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index fe0bf48..4385418 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -28,6 +28,7 @@ #include #include #include +#include struct bpf_verifier_env; struct bpf_verifier_log; @@ -2933,4 +2934,11 @@ static inline bool type_is_alloc(u32 type) return type & MEM_ALLOC; } +static inline gfp_t bpf_memcg_flags(gfp_t flags) +{ + if (memcg_bpf_enabled()) + return flags | __GFP_ACCOUNT; + return flags; +} + #endif /* _LINUX_BPF_H */