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 A27F8CDB474 for ; Fri, 20 Oct 2023 17:58:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D293800B7; Fri, 20 Oct 2023 13:58:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 383958D0003; Fri, 20 Oct 2023 13:58:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24B5A800B7; Fri, 20 Oct 2023 13:58:53 -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 10EDF8D0003 for ; Fri, 20 Oct 2023 13:58:53 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CF25EA077B for ; Fri, 20 Oct 2023 17:58:52 +0000 (UTC) X-FDA: 81366600504.26.FF84187 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by imf22.hostedemail.com (Postfix) with ESMTP id E9702C001B for ; Fri, 20 Oct 2023 17:58:50 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YyXNZT6c; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.221.50 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697824731; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JZ9J4etV4XyxH/p23jplLUii5ZwDC1wU3DhVZOLo/oo=; b=bzrY/HsL7O6pVSv2FUQugrXVx5YFRd/usOFpdR4Ui9YcNqbxmiMHYxc6nuY+bTQ5vv0stK lCU6GwM6HsOctY7H9ZrTBFdWBRctjRYTE8TY+UFj1a1cOkFK7PpuLnd5KUMG6xDle1/1SE WWKqeQ/aBIu2c9TRrclyJsThkQG4YwU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YyXNZT6c; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.221.50 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697824731; a=rsa-sha256; cv=none; b=ES7ZvU78JImohVxmXkrHth6+hZsFGf9VkUx1+ldhGIKeBZiu19eMmiNusZXSx8pmAG92lF clCNAEAUdepE3Kzy3cP8ApPQ1HcYqLmbW8oziSP3CVoI4vseo+DVzPt9n3PHyYF4C0AnR5 frZRW8IGyGG7T8lwY+rR17iBcHPZfHA= Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-32d9effe314so801146f8f.3 for ; Fri, 20 Oct 2023 10:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697824729; x=1698429529; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JZ9J4etV4XyxH/p23jplLUii5ZwDC1wU3DhVZOLo/oo=; b=YyXNZT6cEhUacEgsCVpGKghoj/gD2PKGXhwtt7oQOg58ULabw5sED6hXZDsKj4DZyr b1hZvLs8Miscg3JWMNLsvwgoIDd7uHbqxouGGujRsszbZkYIEzoYgzIWo0PSWurdLYm3 FEdK+LYq2vz+CZ4bjklo+vUtCp0b9jZTlLHG9Z+R+6+e8K3ab5RFVFXkhjocLf5185Wv JOsC8Fs7I6RT+yu+kQW0KMeTICP/K7BUvKkQ0uqXExWB/itkvHhyeDzePxDeTtrG/Msd +/AWferu2SwoZm4l9QhUbHW0fzFpiUgpl3P/rMBGWEB4ML1q17CfpF9dWbmJKp67Vc+2 vDAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697824729; x=1698429529; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JZ9J4etV4XyxH/p23jplLUii5ZwDC1wU3DhVZOLo/oo=; b=mXZdJWPATKN1pmNeqt1/UF9dLeJHqfoGaRiXyWZdI35BWcsdEVz2uAwWZ+/ZcbjPLJ 8NbvbrMfAeczrVDKpanWZZSRLkd0rZfFluFDuVszQdaa64nto2/gWm2kdl6eyizdbTCL ilDjsEpaxaX6aqx9gH5lQCTlmiczeDrGjB4QjZDQKRRXagFi4jBdiiJnqt82AIZa8MLE 8J5uUAHKRLZCUEVZjEVa5d3vN06ML9F8Ob0cklizExwIYbvfAIkvMpArZY0N56ljXY7W Oe/1qVvpZPMRCLmrYLwZXvc9jJfTMm+rq5wCiewPqwCucBks7r7s1CSPfElX8O7nWo5i 1PoA== X-Gm-Message-State: AOJu0YxKik2PtyqZaHX8tPRuFZm9pW+FR20NyH16cAvpSnut6LLXDTa4 VsNZ1IRXXSuEO1z+2bf6oN3JGuhxuM9W+rrBlvQ= X-Google-Smtp-Source: AGHT+IH5kOwPSUcFh1hKA14nYuEsEO//NFyPkZ3EqGrUY7euHnWr2jbBUn4sG8OXxWF8KY9OOsF/YfRI7uBk/47D8cM= X-Received: by 2002:a05:6000:78d:b0:32d:8401:404a with SMTP id bu13-20020a056000078d00b0032d8401404amr2366145wrb.10.1697824729093; Fri, 20 Oct 2023 10:58:49 -0700 (PDT) MIME-Version: 1.0 References: <20231020133202.4043247-1-houtao@huaweicloud.com> <20231020133202.4043247-3-houtao@huaweicloud.com> In-Reply-To: From: Alexei Starovoitov Date: Fri, 20 Oct 2023 10:58:37 -0700 Message-ID: Subject: Re: [PATCH bpf-next v3 2/7] mm/percpu.c: introduce pcpu_alloc_size() To: Dennis Zhou Cc: Hou Tao , bpf , linux-mm , Martin KaFai Lau , Andrii Nakryiko , Song Liu , Hao Luo , Yonghong Song , Daniel Borkmann , KP Singh , Stanislav Fomichev , Jiri Olsa , John Fastabend , Hou Tao , Tejun Heo , Christoph Lameter , Andrew Morton Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E9702C001B X-Stat-Signature: wa5k7b1zezdqib7bgr9gdpd48d1uricr X-Rspam-User: X-HE-Tag: 1697824730-810387 X-HE-Meta: U2FsdGVkX1+cWcG+i1BjnAwaEps6o9iijf6LLJb2XelJCZS+1soLWgXeeEk+5MHVFJgUTbDsEntxzgqvH7Do5MQVI8eIbJ1ppuwjkTXN9sBHVvSEy5WWwB+D1qKqDMFVeYqZtgbLvf0AxEe6/iYLOO5V+BSnoBxivXUFNo2bZDRmuLbIU3Hy+dZ74XpB2MOtorAEEYui0iaPzCLTGi5ptmejYRvbcKO4xpOYZoDAjHxGz7Ogm6Y0dF7vCTQLzvt6JsAWqQA87ORNAs8y3SRFZvoh25o0ldgKTsUAi9x9x7jrYu1BqZgSq+NhVdTH0NiZDjg5HKftchDycQIgnn4/oRKFjDljLthNeORHb9cb5IT+Vt2HjuaqCvDEDbN2C6oSsA///HevhN6yBVCMRBVbC8okhsI7tZBXkSAsmAHYBPJIDqv2KEpFGSx9JHZwsCHBXFaDXTF9vH89htwg5HwYoYt1U6DXqLT2zJFxA8E2/ECvGGg9UdHJ0LCcJzqu3yYcnPRBECS20kRuiPF6s9rNYAGNDuRRoxfOBaIkVdq8nJp/NtlwLIF6FEatG/+uixYQZeCStc4Niqa16UDw21YPbp1HsH9PlMRZOThT4v5yXvH76DglCY281iGtpZ31GmriXLetSW3Y3Zr2q8QqXgQG9iJ7UBiTC7gbKqa17OLiizDl2YS8s6ImI8PYcRl7/yNjxp92MM6m5+ppBCBSJPa/ZgBRAqNKX9na+JUtbBJSaer0oOpdQF/Vvs7VlQsZMDoCwQNg3ONQVlgPBMl/T4xMV7z04891tPMX8dmttOV8k77pRu6oINruR4NeJyQIrUlxUmrewTZtCak/5Nil3oBucqLeX5xhtpBEFebA9TS8x0lZJvViM0FCeYH3cjVCKREm5QRBad6Q+nboAtHmZ8BwG1tvKrKCD8vopQGVz7otOhhB1fybNZQc4boTAzk2PLWhpFtkn7Jer048iWgWQIA LfgYGqjt 5RcKnUvGQpar94J15DjAm84dnr8Uxosr+FMPwjf0PcWU4EuL2vNr6qIWaJp+uJl2JyHeNhpapMLohjTgDYoLsDrS3tZ7spGkGZB1pTAVlh0Z/z7dm0KjKAWUUc7s1RLqaYoONKnyosExQZY/U7+jXiWSgzokFMLGbGB3/9/Zdu/tuz1QQIsrVTsgFDyc5OpXnCzSUJ+rfoyky2DhoNA2YZDea6PTTZ53c3xLMUxW3vu84U77Fcr5NKoolAUq3Po4RAPJi58a0PaPKh1iz+wyKB1eju1R2nJ1E/hVkWvSL6HiX4cfmlGzvRrPW/s2ey/6L3fqdWg5735U+5Z9wM9pxnPW+FpEalRIufiJeNYRbV+aNQoqCu5k0d/ON//PYHRsEJ0B9PIgZ9Z6404arjBo+EYXIv79cxjJvDrgVQ96asfUuKsGHJ1NfV/4mb2DHeGSusoGLvNBNGFPUtuAiw+Ars6vCC+EKmrLooLDGxiLU4Ie31TLuc4kZEiC5EbAolc6WQjGgH1SqjTWfA10QVIePExphFKRM/8DDVIUi8bKE6/di6ri3HsOaBUta8vPd7jbd63XUChz9qoGlEjI= 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 Fri, Oct 20, 2023 at 10:48=E2=80=AFAM Dennis Zhou wr= ote: > > On Fri, Oct 20, 2023 at 09:31:57PM +0800, Hou Tao wrote: > > From: Hou Tao > > > > Introduce pcpu_alloc_size() to get the size of the dynamic per-cpu > > area. It will be used by bpf memory allocator in the following patches. > > BPF memory allocator maintains per-cpu area caches for multiple area > > sizes and its free API only has the to-be-freed per-cpu pointer, so it > > needs the size of dynamic per-cpu area to select the corresponding cach= e > > when bpf program frees the dynamic per-cpu pointer. > > > > Acked-by: Dennis Zhou > > Signed-off-by: Hou Tao > > --- > > include/linux/percpu.h | 1 + > > mm/percpu.c | 31 +++++++++++++++++++++++++++++++ > > 2 files changed, 32 insertions(+) > > > > diff --git a/include/linux/percpu.h b/include/linux/percpu.h > > index 68fac2e7cbe67..8c677f185901b 100644 > > --- a/include/linux/percpu.h > > +++ b/include/linux/percpu.h > > @@ -132,6 +132,7 @@ extern void __init setup_per_cpu_areas(void); > > extern void __percpu *__alloc_percpu_gfp(size_t size, size_t align, gf= p_t gfp) __alloc_size(1); > > extern void __percpu *__alloc_percpu(size_t size, size_t align) __allo= c_size(1); > > extern void free_percpu(void __percpu *__pdata); > > +extern size_t pcpu_alloc_size(void __percpu *__pdata); > > > > DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) > > > > diff --git a/mm/percpu.c b/mm/percpu.c > > index 76b9c5e63c562..1759b91c8944a 100644 > > --- a/mm/percpu.c > > +++ b/mm/percpu.c > > @@ -2244,6 +2244,37 @@ static void pcpu_balance_workfn(struct work_stru= ct *work) > > mutex_unlock(&pcpu_alloc_mutex); > > } > > > > +/** > > + * pcpu_alloc_size - the size of the dynamic percpu area > > + * @ptr: pointer to the dynamic percpu area > > + * > > + * Returns the size of the @ptr allocation. This is undefined for stat= ically > ^ > > Nit: Alexei, when you pull this, can you make it a double space here? > Just keeps percpu's file consistent. Argh. Already applied. That's a very weird style you have in a few places. $ grep '\. [A-z]' mm/*.c|wc -l 1118 $ grep '\. [A-z]' mm/*.c|wc -l 2451 Single space is used more often in mm/* and in the rest of the kernel. $ grep '\. [A-z]' mm/percpu.c|wc -l 10 percpu.c isn't consistent either. I can force push if you really insist.