Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5416221imm; Tue, 31 Jul 2018 10:31:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfJsDYGtl/Lauc0BQ4sUBAmRt2oE7/7l73s6woYMwmJPFWjopX7lBXASfijq12Zz8qcDNhO X-Received: by 2002:a63:d613:: with SMTP id q19-v6mr21270757pgg.327.1533058264552; Tue, 31 Jul 2018 10:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533058264; cv=none; d=google.com; s=arc-20160816; b=QPlpe/yYdObKl9W37mDTRHxs/si6SEA5X7Sig2ZRgBDTJYXf8yuKi0uFF/R/ZyFtXB PMg7teX4vkgvF1l1Tpt0cIlPiznJ9tR2MaWV4BDEdCN9qxq2CaGuKjeN9rMkA/KcgMG6 aTPOEuQj5G/G1PZKrVXMLO5IZkQmfM+db+6TtW17CL5ImaeUGoTE6D07quyVIv7SubhA 18dLItiGa/AeWwzLqnFGL9Z9oNHcZG47t+kRJE2Pl6d1VtiG/cJU3pNnb0xFLSj+bM6v u00aaAm38W20ouAaQMl17SaRceiZFf/Iw34lyXMivwzr4FYwYA+lqn3nY0CmLDGSRUeN Wa8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature:arc-authentication-results; bh=vqCT8cjYkJ7br6DQutaXNO/3K9QaE7v/5fCp1oS8JJc=; b=gJQ6XSlVXkF2iaLpjis/nOwFL40BLqaAiFukjJckbb04nUJqY3dGynfyM/qJT5q259 JzObC+1t68vINkx2hE0rOSszwVDwtpuGHBnwupVT4MYDLjEcvvtzrHvYZybzLaEvJzRo yhxWoBG89ozPLe39nydedD7+ul7jZRWG+XouS2A5Fql5uuCsnGB7eQAoeJXG+eTI3fGE lisnXuExnrs5J5JDmMf+y0lxl3LoomtyaPEctk68NALnL6iRCkcetuicW7r2kH7wOuTk RHtuYAsIepZWsjTJVj4j/vL4sq7ThzE6D+fLQ5LRvYwJ2nrWAXcbnIoVgGLCyisUur1s 1UhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=eBGHA+T9; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=XXtsi8js; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d27-v6si12342496pgm.67.2018.07.31.10.30.49; Tue, 31 Jul 2018 10:31:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=eBGHA+T9; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=XXtsi8js; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730513AbeGaTGw (ORCPT + 99 others); Tue, 31 Jul 2018 15:06:52 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:50566 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729636AbeGaTGw (ORCPT ); Tue, 31 Jul 2018 15:06:52 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6VHO9dC000305; Tue, 31 Jul 2018 10:25:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=vqCT8cjYkJ7br6DQutaXNO/3K9QaE7v/5fCp1oS8JJc=; b=eBGHA+T92lrTCfIvJGk6rp1ppZmnDwLxAJn57eOL949cRCeN6PbaysSyPvaJDlYRM+KP vIh/tvUsLtpNCWc7BF6lADF5KgOVL2bvqm3xCLKoj8VbEIrOSZJWJRHk2ps8Yn70Ys4W imTQyVnlUZSD7nj7rIed6ZRKv1a6X15Hkzc= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2kjshm0p2t-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 31 Jul 2018 10:25:10 -0700 Received: from NAM05-DM3-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.19) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 31 Jul 2018 10:25:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vqCT8cjYkJ7br6DQutaXNO/3K9QaE7v/5fCp1oS8JJc=; b=XXtsi8js1Lg5Et0Ej2wUqtdmhuoAw2Tm3TIgQKG0MW2rgkaZ+8L/6X6GSkNEJM9AGqyooYrfOhrxTgLOfZErJuBxFVuzz8tmsj1zYthtwi67Inp0LT9Q+WEUUKOGzuf+VZctawfkWAsfh9PIA6bOPy5e+IKxZKBsMruM6YqmDs4= Received: from castle.DHCP.thefacebook.com (2620:10d:c090:200::7:6a14) by BLUPR15MB0161.namprd15.prod.outlook.com (2a01:111:e400:5248::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.18; Tue, 31 Jul 2018 17:25:04 +0000 Date: Tue, 31 Jul 2018 10:24:58 -0700 From: Roman Gushchin To: Daniel Borkmann CC: , , , Alexei Starovoitov Subject: Re: [PATCH v4 bpf-next 08/14] bpf: introduce the bpf_get_local_storage() helper function Message-ID: <20180731172455.GA7535@castle.DHCP.thefacebook.com> References: <20180727215243.3850-1-guro@fb.com> <20180727215243.3850-9-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-Originating-IP: [2620:10d:c090:200::7:6a14] X-ClientProxiedBy: MWHPR21CA0061.namprd21.prod.outlook.com (2603:10b6:300:db::23) To BLUPR15MB0161.namprd15.prod.outlook.com (2a01:111:e400:5248::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6ec0fa9-4a31-4976-f65f-08d5f70a8e2c X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:BLUPR15MB0161; X-Microsoft-Exchange-Diagnostics: 1;BLUPR15MB0161;3:Y/cGpwLEY2VzPGv9/OcaW9GaR+hVOvo4sRqO4YJu5yXjVnVxUcuHAXq4+MNpY8isrm5fdUrzZZbdM+GTeUqY/Cy7aC3LvRTDeQ7iVmwjJHh58RA/06qgb1cUQftt6R7dXTbeNj3/JDIlCIF6xFpWFcu39oB8L85IqCGJo0R8Bj1tah/M8hpyJNdxs2KyTt4tiEZBGuJCK4JvIKdc/HaStjxXyobRdaatXtGyv7/JMSJiNg+ImpshBE3hsk45kYIC;25:qNxT7cskxcAUW3/wxds+z3apXEMKCtHytwUGFST5IE6HxSxQ3RaGxxJY77Dy9sSbOMqtqwROxfdEGT8dZapgAsR51pfA316nGCbZO3vkyphMdAxM/KDIWe1YuBDlh69gw1Xys+O1BCLQrldDd6Lc5bI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R1ijnQX5dLWlhCoOfdl0yEwjzT8ZlfTyN88j1AQAuc83V7OsLMs2ASJNMzaBEWx3kJ3PMef5+EiqblRNrn/nJU8LTlUYCKrUlrerillsavT/bRaEPSMGgHlrpO1KeoSBzqSc/gBITKSMpa5cLMieG8jy6wviX/9q9lyFpCx+AfBTpAnzdxI9XZxbtA2Dz5PXZrDMlixvmcKFgoYHV/znef1aMbVlCiaK3VJ/oNe7zIzoIcOt4EWT1OUVMOBeJZ9JfnFP17 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231311)(11241501184)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(149027)(150027)(6041310)(201703131423095)(201703061421075)(201703161042150)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6042181)(6072148)(201708071742011)(7699016);SRVR:BLUPR15MB0161;BCL:0;PCL:0;RULEID:;SRVR:BLUPR15MB0161; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(189003)(199004)(106356001)(2906002)(47776003)(7736002)(33656002)(5660300001)(25786009)(8936002)(498600001)(97736004)(23726003)(4326008)(305945005)(81166006)(81156014)(8676002)(105586002)(50466002)(16586007)(58126008)(6246003)(575784001)(14444005)(86362001)(6116002)(52396003)(186003)(486006)(16526019)(7696005)(52116002)(446003)(386003)(9686003)(76176011)(6506007)(53546011)(46003)(68736007)(6916009)(53936002)(6666003)(55016002)(476003)(229853002)(11346002)(1076002)(18370500001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR15MB0161;H:castle.DHCP.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-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aDCVNk3l1VIN+8OXdbDxxPaI220NAQRBSz+kXPLwY97HnQPkdapW4T6cwnuUiZ8rJ7tlBLMD3pLVYnh892SkSsFyH9d/zPNxSh40dnT7ySDVtXfxcK58OkkD8CWN5TBiJ8odz7riWqMa1n7NlXhBqEtXL5p2yhUhDG5FXrmeCHiKf79tbMTWgczKPEnJ5J6V6+6RNJgrxGd5uyPbTD6bxIJOBfv4Ufnj8zzW4xQ==;5:JwOoc6b3mtGOKI+ZBOfvgP/PTWIIrRli1gBAFnpEka7om40NvwJ/uIxtYyh8APRQWGT0k9pAYIdOj5jbeqiZT1XbKFuvSQ9WsGiB+oakdlJJbAby4ONefhyRlpuN+hEXj1+07X7l+6LEbmosnGF1CT5gniUUW2dKn2h7nzhrKKw=;7:4KlL2BTjdxg0N4Bf3ikjvL+Bfr/YgINRWWgwqn2WV43gBfAitPN/TC6SSS0gpdYTQPIUII986K6tnd4luYU9VnNSFHhup59einQv3s5QyzXWsOIWpfJcYfR8VtHZhX1PU5CoawEn9oPpb5rlDQqqQeCRudhM85DZ/I68/x+HJ49Y60VbWx5ahB/8b7rtMv+q8xpxNYz09pipnjGj3MOZYisuyxT42QkRom+aNxPMhz667H9LEpy/133Agq8dXLux SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR15MB0161;20:XGFt7mmgs4R9nCBxgTI4c50Xq04OHYq3to/Dza3oaDaPCU0gke/YXjLnoOo70q6wkupJG01GrKioCuCizAF/U/ET7KfQyIicSidtxMSbghJVTS/BR/yxEEuiIcpS2Zn3mD7RzvO+sC5IMjqYAL26iDjujL9O5FeN88O4y+9b5SA= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 17:25:04.1781 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6ec0fa9-4a31-4976-f65f-08d5f70a8e2c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR15MB0161 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-31_07:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 31, 2018 at 12:34:06PM +0200, Daniel Borkmann wrote: > Hi Roman, > > On 07/27/2018 11:52 PM, Roman Gushchin wrote: > > The bpf_get_local_storage() helper function is used > > to get a pointer to the bpf local storage from a bpf program. > > > > It takes a pointer to a storage map and flags as arguments. > > Right now it accepts only cgroup storage maps, and flags > > argument has to be 0. Further it can be extended to support > > other types of local storage: e.g. thread local storage etc. > > > > Signed-off-by: Roman Gushchin > > Cc: Alexei Starovoitov > > Cc: Daniel Borkmann > > Acked-by: Martin KaFai Lau > > --- > > include/linux/bpf.h | 2 ++ > > include/uapi/linux/bpf.h | 13 ++++++++++++- > > kernel/bpf/cgroup.c | 2 ++ > > kernel/bpf/core.c | 1 + > > kernel/bpf/helpers.c | 20 ++++++++++++++++++++ > > kernel/bpf/verifier.c | 18 ++++++++++++++++++ > > net/core/filter.c | 23 ++++++++++++++++++++++- > > 7 files changed, 77 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > > index ca4ac2a39def..cd8790d2c6ed 100644 > > --- a/include/linux/bpf.h > > +++ b/include/linux/bpf.h > > @@ -788,6 +788,8 @@ extern const struct bpf_func_proto bpf_sock_map_update_proto; > > extern const struct bpf_func_proto bpf_sock_hash_update_proto; > > extern const struct bpf_func_proto bpf_get_current_cgroup_id_proto; > > > > +extern const struct bpf_func_proto bpf_get_local_storage_proto; > > + > > /* Shared helpers among cBPF and eBPF. */ > > void bpf_user_rnd_init_once(void); > > u64 bpf_user_rnd_u32(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > > index a0aa53148763..495180f229ee 100644 > > --- a/include/uapi/linux/bpf.h > > +++ b/include/uapi/linux/bpf.h > > @@ -2081,6 +2081,16 @@ union bpf_attr { > > * Return > > * A 64-bit integer containing the current cgroup id based > > * on the cgroup within which the current task is running. > > + * > > + * void* get_local_storage(void *map, u64 flags) > > + * Description > > + * Get the pointer to the local storage area. > > + * The type and the size of the local storage is defined > > + * by the *map* argument. > > + * The *flags* meaning is specific for each map type, > > + * and has to be 0 for cgroup local storage. > > + * Return > > + * Pointer to the local storage area. > > */ > > I think it would be crucial to clarify what underlying assumption the > program writer can make with regards to concurrent access to this storage. > > E.g. in this context, can _only_ BPF_XADD be used for counters as otherwise > any other type of access may race in parallel, or are we protected by the > socket lock and can safely override all data in this buffer via normal stores > (e.g. for socket related progs)? What about other types? > > Right now nothing is mentioned here, but I think it must be clarified to > avoid any surprises. E.g. in normal htab case program can at least use the > map update there for atomic value updates, but those are disallowed from > the cgroup local storage, hence my question. Btw, no need to resend, I can > also update the paragraph there. Fair enough. Mid- to long-term we want to add a per-cpu version of the cgroup local storage, and, possible, some locking API. But right now XADD is what should be used. I think something like this should work here: -- Depending on the bpf program type, a local storage area can be shared between multiple instances of the bpf program, running simultaneously. A user should care about the synchronization by himself. For example, by using BPF_STX_XADD instruction to alter the shared data. -- Please, feel free to change/add to the text above. Also, it might be good to change the example to use STX_XADD: index 0597943ce34b..dc83fb2d3f27 100644 --- a/tools/testing/selftests/bpf/test_cgroup_storage.c +++ b/tools/testing/selftests/bpf/test_cgroup_storage.c @@ -18,9 +18,9 @@ int main(int argc, char **argv) BPF_MOV64_IMM(BPF_REG_2, 0), /* flags, not used */ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_get_local_storage), + BPF_MOV64_IMM(BPF_REG_1, 1), + BPF_STX_XADD(BPF_DW, BPF_REG_0, BPF_REG_1, 0), BPF_LDX_MEM(BPF_W, BPF_REG_1, BPF_REG_0, 0), - BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 1), - BPF_STX_MEM(BPF_DW, BPF_REG_0, BPF_REG_1, 0), BPF_ALU64_IMM(BPF_AND, BPF_REG_1, 0x1), BPF_MOV64_REG(BPF_REG_0, BPF_REG_1), BPF_EXIT_INSN(), Thank you! Roman