Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp635551imm; Wed, 26 Sep 2018 04:35:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV607w7W+7RI/qacX6y+jH8+QONls4upMD23SIxOpRDcbPvC4HIhW9/QDl2wlV+menWLpi/wj X-Received: by 2002:a62:d206:: with SMTP id c6-v6mr5955485pfg.8.1537961721244; Wed, 26 Sep 2018 04:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537961721; cv=none; d=google.com; s=arc-20160816; b=zixuqUgUbDBV/OloF82BS9Mo9XC+e2F6hNa5/SHhUTzCgdofZVAR8/ngdlFMSMIJz0 Q+3FijFDbu3ueCn+UCnN7HV79ULgy2rCn5HFy6nD9YRmthfm/EGgXLP2NNey//WKyP7b 0cGqNePFjSzgAe/qd3jbbnlxhBrptVKIN8SlCpwZTGFx1N84h+EmTWCZ5HHszu+ekrIO Q4PZPeNC4tvxQfnewoWtJ8Bh4gplGH1Z/fFJpKIoiYy7elKUYOIrCcxHu+kJgQvlXBUD wgZEVIj/Fb/aHc/6rYtKlObyQAM4/5fdOXKP/0bcmwTwikOxf3OIEOz0V6t/P4943cMZ dR2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=85egIdVuiuZ9M5KELnH3tIbiuDDQlOmhQrwiPQn3UaI=; b=YO6iy/pPGK/6Mur4wZRrn107aENDG0IqGhZfjP5VggeRMzQcGxKRelQnCgF6huFPrP eKvTeTgKWuEFsxJ6FyNlsghiJfqcVE1z/S87t287wkV8yL4EM5TxzTH0gGCIhl9i4kjD 1ivE3vJ9ENRv8p/X7vpbMGndn0p4XlORYXw5eV1s4A2wH+4AKwf1eqLC9vsjpmMq2KnV 6DP/BX++d21/XeR0+OKkZJxFuRVq4qVfGzHbdykxUp60mR2i/btvzF64qVEocRgmYd0M m0BlrwVIxlzRz0RDIMtjLm9Shw+IilG0P9SVMKR4jw5jm6ad2gqCP51e9hZHJSGUfIRj QPnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=oUPl06FS; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=DLBGGsQr; 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 s25-v6si5267592pgd.539.2018.09.26.04.35.05; Wed, 26 Sep 2018 04:35:21 -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=oUPl06FS; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=DLBGGsQr; 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 S1728351AbeIZRq5 (ORCPT + 99 others); Wed, 26 Sep 2018 13:46:57 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:33158 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726937AbeIZRqz (ORCPT ); Wed, 26 Sep 2018 13:46:55 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8QBQxpm017644; Wed, 26 Sep 2018 04:34:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=85egIdVuiuZ9M5KELnH3tIbiuDDQlOmhQrwiPQn3UaI=; b=oUPl06FS+vhVmUXianugWg/aZH1iSW7c7Ju0bTf/aa8LBinLwYkius2CzhyRrnWB6yy0 HmWBnrEgsi3FaP1vKtd3Nr+snlntQk8UcQZwID+3n8iiC9f43hpyoKaq8Y0l2KK3oGW3 yhlU0WtKb7i9xAYdOnkSfxCnfIK+qLNTOsg= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0b-00082601.pphosted.com with ESMTP id 2mqxqpsevd-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 26 Sep 2018 04:34:03 -0700 Received: from NAM01-BY2-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.30) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 26 Sep 2018 07:34:02 -0400 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=85egIdVuiuZ9M5KELnH3tIbiuDDQlOmhQrwiPQn3UaI=; b=DLBGGsQr8N9sA0CeQph9KNDknmliE0zUzT8p0yGGevuSFDKvMkJ0+qbV3xhwcdMTV65hdq7snc6JXU+8yRUC8tBOjhGbcvLw9UD7o6NoYD2yAhO9fn9dGyUDtQqhOPwEVnmDTLQ0l+nzp1YCmi5scBwCeNvrEJQl/rzmchzpSPM= Received: from castle.thefacebook.com (2620:10d:c092:200::1:15cb) by BLUPR15MB0162.namprd15.prod.outlook.com (2a01:111:e400:5249::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.20; Wed, 26 Sep 2018 11:33:58 +0000 From: Roman Gushchin To: CC: Song Liu , , , Roman Gushchin , Daniel Borkmann , Alexei Starovoitov Subject: [PATCH v3 bpf-next 08/10] selftests/bpf: extend the storage test to test per-cpu cgroup storage Date: Wed, 26 Sep 2018 12:33:24 +0100 Message-ID: <20180926113326.29069-9-guro@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926113326.29069-1-guro@fb.com> References: <20180926113326.29069-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:15cb] X-ClientProxiedBy: AM6P193CA0005.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:3e::18) To BLUPR15MB0162.namprd15.prod.outlook.com (2a01:111:e400:5249::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75e84a8b-b742-4c75-cb16-08d623a3f3e2 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BLUPR15MB0162; X-Microsoft-Exchange-Diagnostics: 1;BLUPR15MB0162;3:zq0kpxjMG2RtyZsKrE/i7xkZHAWpMYLDW1ysldfUDtA+k/nl10VXpcIdwxH3xePrueZWDhHldOXWT4oAbkaRHQRpurtPGmI1xUMPt4q0k8LKc3UBlL6hXdbXJnARO8O6+L0OhP2XbBPDs4IhWNQvEakWUXVIHRjlSuyaD0Q3tmCamIwYaSEuEg4j0chRxt/+xhdzHIWuJUspUZZgkw4aoCaOp9x7mdcIasBfuTmawuEL6HswnZcEOQek9yh5xJ1x;25:hNVSDFL5d9A3WMEdMungQqszTH3w+3z5X5Zqe1Uh8uvvqoioesGG8SsCo1zdO/jLrKja0Qr4dVdtmvBN8AzhYKDMNuZgBEJ6wVMSEC90raPkn9NO2/5zU/PZe+pwuDQWAYr0PnZRz0upIEn63gQEDA1EKvvJ0csiyqnRac83zRTRYAxzagsCUQ8GFlsl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ksyC0+u2hkc3BFVZAHBV0E2A/3zSiwnOC4dMB17rvclUbGUkOXIepWpYCyUY/FYL8e1Eju+5Z4Tn5bc4bLMzwtqbTqL5TEqabDKH4A9tBK1Mb5/4h5R5LAR1DxliLo3nHjCu2Be6DROzYsbrO5MBI2ShzzbsSz9A+NiXNkceHD9ZbmxTIAtFDQu8xHb28WL/KtB7EVm3sy2UTBZ5xDoJ98FvPTyP5v28P 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)(823302057)(3002001)(10201501046)(3231355)(11241501184)(944501410)(52105095)(93006095)(93001095)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051);SRVR:BLUPR15MB0162;BCL:0;PCL:0;RULEID:;SRVR:BLUPR15MB0162; X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(346002)(376002)(136003)(366004)(396003)(39860400002)(199004)(189003)(446003)(16526019)(478600001)(8936002)(46003)(186003)(11346002)(36756003)(52116002)(51416003)(52396003)(76176011)(97736004)(2616005)(4326008)(7736002)(50226002)(305945005)(476003)(2906002)(486006)(106356001)(6512007)(2351001)(48376002)(69596002)(6116002)(50466002)(1076002)(53416004)(47776003)(105586002)(53936002)(6506007)(8676002)(16586007)(386003)(54906003)(25786009)(6486002)(2361001)(81166006)(316002)(81156014)(551984002)(86362001)(14444005)(5660300001)(6916009)(6666003)(34290500001)(68736007)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR15MB0162;H:castle.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange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ITOFOwCUqMGSnBnGmqTsdOVcVA= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 11:33:58.8994 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75e84a8b-b742-4c75-cb16-08d623a3f3e2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR15MB0162 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-26_06:,, 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 This test extends the cgroup storage test to use per-cpu flavor of the cgroup storage as well. The test initializes a per-cpu cgroup storage to some non-zero initial value (1000), and then simple bumps a per-cpu counter each time the shared counter is atomically incremented. Then it reads all per-cpu areas from the userspace side, and checks that the sum of values adds to the expected sum. Expected output: $ ./test_cgroup_storage test_cgroup_storage:PASS Signed-off-by: Roman Gushchin Acked-by: Song Liu Cc: Daniel Borkmann Cc: Alexei Starovoitov --- .../selftests/bpf/test_cgroup_storage.c | 60 ++++++++++++++++++- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/test_cgroup_storage.c b/tools/testing/selftests/bpf/test_cgroup_storage.c index 4e196e3bfecf..f44834155f25 100644 --- a/tools/testing/selftests/bpf/test_cgroup_storage.c +++ b/tools/testing/selftests/bpf/test_cgroup_storage.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "bpf_rlimit.h" #include "cgroup_helpers.h" @@ -15,6 +16,14 @@ char bpf_log_buf[BPF_LOG_BUF_SIZE]; int main(int argc, char **argv) { struct bpf_insn prog[] = { + BPF_LD_MAP_FD(BPF_REG_1, 0), /* percpu map fd */ + 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_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0), + BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 0x1), + BPF_STX_MEM(BPF_W, BPF_REG_0, BPF_REG_3, 0), + BPF_LD_MAP_FD(BPF_REG_1, 0), /* map fd */ BPF_MOV64_IMM(BPF_REG_2, 0), /* flags, not used */ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, @@ -28,9 +37,18 @@ int main(int argc, char **argv) }; size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn); int error = EXIT_FAILURE; - int map_fd, prog_fd, cgroup_fd; + int map_fd, percpu_map_fd, prog_fd, cgroup_fd; struct bpf_cgroup_storage_key key; unsigned long long value; + unsigned long long *percpu_value; + int cpu, nproc; + + nproc = get_nprocs_conf(); + percpu_value = malloc(sizeof(*percpu_value) * nproc); + if (!percpu_value) { + printf("Not enough memory for per-cpu area (%d cpus)\n", nproc); + goto err; + } map_fd = bpf_create_map(BPF_MAP_TYPE_CGROUP_STORAGE, sizeof(key), sizeof(value), 0, 0); @@ -39,7 +57,15 @@ int main(int argc, char **argv) goto out; } - prog[0].imm = map_fd; + percpu_map_fd = bpf_create_map(BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE, + sizeof(key), sizeof(value), 0, 0); + if (percpu_map_fd < 0) { + printf("Failed to create map: %s\n", strerror(errno)); + goto out; + } + + prog[0].imm = percpu_map_fd; + prog[7].imm = map_fd; prog_fd = bpf_load_program(BPF_PROG_TYPE_CGROUP_SKB, prog, insns_cnt, "GPL", 0, bpf_log_buf, BPF_LOG_BUF_SIZE); @@ -77,7 +103,15 @@ int main(int argc, char **argv) } if (bpf_map_lookup_elem(map_fd, &key, &value)) { - printf("Failed to lookup cgroup storage\n"); + printf("Failed to lookup cgroup storage 0\n"); + goto err; + } + + for (cpu = 0; cpu < nproc; cpu++) + percpu_value[cpu] = 1000; + + if (bpf_map_update_elem(percpu_map_fd, &key, percpu_value, 0)) { + printf("Failed to update the data in the cgroup storage\n"); goto err; } @@ -120,11 +154,31 @@ int main(int argc, char **argv) goto err; } + /* Check the final value of the counter in the percpu local storage */ + + for (cpu = 0; cpu < nproc; cpu++) + percpu_value[cpu] = 0; + + if (bpf_map_lookup_elem(percpu_map_fd, &key, percpu_value)) { + printf("Failed to lookup the per-cpu cgroup storage\n"); + goto err; + } + + value = 0; + for (cpu = 0; cpu < nproc; cpu++) + value += percpu_value[cpu]; + + if (value != nproc * 1000 + 6) { + printf("Unexpected data in the per-cpu cgroup storage\n"); + goto err; + } + error = 0; printf("test_cgroup_storage:PASS\n"); err: cleanup_cgroup_environment(); + free(percpu_value); out: return error; -- 2.17.1