From patchwork Fri Feb 22 08:46:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 159003 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1473306jaa; Fri, 22 Feb 2019 00:47:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IZnjByNyE7SgWEjVfySXiHpqhZ1PF3Kit4aO5+3tE8h30vdIH2dxZQoRTeFERz+1dT2EOQq X-Received: by 2002:a62:fc10:: with SMTP id e16mr3120649pfh.83.1550825230522; Fri, 22 Feb 2019 00:47:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550825230; cv=none; d=google.com; s=arc-20160816; b=Q0SPJtq9gnmpJDv/ac0jU6ttAFVQAMi5zhVSgBmzasiaX6DpnznA9kuNn0sRDO+3KM hK7zLNwrQ+DAVTWQTcYV8sXvY6lXXygQq7lq3wmkshVxzduBOlvuzYXPHnuUgCHIiUy2 y7/Tc2dS1dyUapcUaWtngHgXjlu3y6yX/Aq3ER8ZbdsaglR94c7HF1MENGjZTkHOaA7s dAl1yILg201o92WyGVSo5YW0B+NPx0xe7vZ5FL8HI89sQ5Bgd7XgHTOwfWHdgQ8s3k0f gzyeq0R/KTOpRA+132Gq1UdbSuNfK2Ggt3u6lV2neOjSPZC0HiFrM9p/C5Al93O9LM9W TxqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ETZpFB6qJCxlI0IxAQXLgBRS8xsxl7FpE0AKXNpfHcc=; b=lUHwnnrtmYxF8Xj9degsa9nfKj+NmpEoZvF3dm59J1CppiEbMvusDF7dMMPCHiUgeX +h2a4yrtE6mefJOXW8BiXn6Sjv7zcOSw0lyn79izW9PQtpnPyVLSQJ6nHgDc9hsemHFH W5BLTogdy6wIgto6t1V7Qz7p1RXjDNQVEU874s0yPcaCxZlu2ZA5crXmh4gynuUtZRpD 277L9+4AtE+mcUy+UC8XRXrLZdOVA4qyudLHLes0OAvdRF/3i6YMEHa2VCRlIPoCSDQu F6PN32Sg74h5wxsxNJz8yHBgr3fSv5mhMcQg2SYk0TwxOJyBK5n0607vZx4FwI+aUoOr UufQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NG8A+5zD; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si872368pgl.106.2019.02.22.00.47.09; Fri, 22 Feb 2019 00:47:10 -0800 (PST) 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=@linaro.org header.s=google header.b=NG8A+5zD; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726632AbfBVIrI (ORCPT + 32 others); Fri, 22 Feb 2019 03:47:08 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33456 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbfBVIrH (ORCPT ); Fri, 22 Feb 2019 03:47:07 -0500 Received: by mail-lj1-f195.google.com with SMTP id z7so873171lji.0 for ; Fri, 22 Feb 2019 00:47:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ETZpFB6qJCxlI0IxAQXLgBRS8xsxl7FpE0AKXNpfHcc=; b=NG8A+5zD+mICdf4JNSR355725NfBQRGbY4mWguL8wD5XfuQVzTnbFppbDUY1Yt30du ujPTECWNc43+reiXYYD6j2Uutnc23objJ2gZH6Y8cahbS12DVm061xXlJf15AAeOh31f R7/p88kS3bpBD5ngNcpr3ldlcIE/2dwfuZl/Mj9he2Q8So8/5KcZRGdDso2Ly992dmX0 peADa74zD+FZJTSE2N9oM2J8/2UnfDv15anoNydIQRqxCJ129gLQulwMbBgMFpf/jQDF tznKGpDsny73cAn9pUMnlNS0pbBrPL6U5PSwEVmf0jJXeK3UkGENYV5G0gT8rNj7KY+v 1EvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ETZpFB6qJCxlI0IxAQXLgBRS8xsxl7FpE0AKXNpfHcc=; b=Ik3tnMF5f+H2cTn1oEZJw2VgxlCY0ciOCXmx2B2NQBGlotHvR/mku8zw2SXbzH9H9l tWIfB4aQAwzsIssok4MGUZYEI5+bsQYC0/XTB07zOkgNKIWZiYxY7i9b+O0LEh1UgKKi 1VDclg4ulsJocVnJ33Pz96LQYqm63ckr68iLgZP21v+sRFZnrr6+dAT8ii2vpnPQa5My inGrB7Nr/aDyHD6rjUP6JH/LU6+JztKollxDPP+2Hkfb6Oay35LdzJi9hl009fHKmZL2 3B6tCYMtnZ5S63GSM20HxuE0tSkOCElkXvf9cDaUuTmitZ6DToySmmAclnAxaeOBcDrz C/oQ== X-Gm-Message-State: AHQUAuZE+3qOaf7rSfvPPfkZncmGl8Vbd7fI5bjIIRjQi6PzuLBs7HVj Du3ozEPGeMVIwp+7RttsxHKFqg== X-Received: by 2002:a2e:b1d1:: with SMTP id e17mr1716300lja.120.1550825225616; Fri, 22 Feb 2019 00:47:05 -0800 (PST) Received: from localhost (c-573670d5.07-21-73746f28.bbcust.telenor.se. [213.112.54.87]) by smtp.gmail.com with ESMTPSA id z26sm284506lja.33.2019.02.22.00.47.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 00:47:05 -0800 (PST) From: Anders Roxell To: ast@kernel.org, daniel@iogearbox.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Anders Roxell , Arnd Bergmann Subject: [PATCH v2] bpf: test_bpf: turn of preemption in function __run_once Date: Fri, 22 Feb 2019 09:46:52 +0100 Message-Id: <20190222084652.1326-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running BPF test suite the following splat occurs: [ 415.930950] test_bpf: #0 TAX jited:0 [ 415.931067] BUG: assuming atomic context at lib/test_bpf.c:6674 [ 415.946169] in_atomic(): 0, irqs_disabled(): 0, pid: 11556, name: modprobe [ 415.953176] INFO: lockdep is turned off. [ 415.957207] CPU: 1 PID: 11556 Comm: modprobe Tainted: G W 5.0.0-rc7-next-20190220 #1 [ 415.966328] Hardware name: HiKey Development Board (DT) [ 415.971592] Call trace: [ 415.974069] dump_backtrace+0x0/0x160 [ 415.977761] show_stack+0x24/0x30 [ 415.981104] dump_stack+0xc8/0x114 [ 415.984534] __cant_sleep+0xf0/0x108 [ 415.988145] test_bpf_init+0x5e0/0x1000 [test_bpf] [ 415.992971] do_one_initcall+0x90/0x428 [ 415.996837] do_init_module+0x60/0x1e4 [ 416.000614] load_module+0x1de0/0x1f50 [ 416.004391] __se_sys_finit_module+0xc8/0xe0 [ 416.008691] __arm64_sys_finit_module+0x24/0x30 [ 416.013255] el0_svc_common+0x78/0x130 [ 416.017031] el0_svc_handler+0x38/0x78 [ 416.020806] el0_svc+0x8/0xc Rework so that preemption is disabled when we loop over function 'BPF_PROG_RUN(...)'. Commit 568f196756ad ("bpf: check that BPF programs run with preemption disabled") highlighted the issue. Suggested-by: Arnd Bergmann Signed-off-by: Anders Roxell --- lib/test_bpf.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.1 diff --git a/lib/test_bpf.c b/lib/test_bpf.c index f3e570722a7e..0845f635f404 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -6668,12 +6668,14 @@ static int __run_one(const struct bpf_prog *fp, const void *data, u64 start, finish; int ret = 0, i; + preempt_disable(); start = ktime_get_ns(); for (i = 0; i < runs; i++) ret = BPF_PROG_RUN(fp, data); finish = ktime_get_ns(); + preempt_enable(); *duration = finish - start; do_div(*duration, runs);