From patchwork Mon Jul 18 19:28:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12921671 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 5171AC433EF for ; Mon, 18 Jul 2022 19:29:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D27D194000F; Mon, 18 Jul 2022 15:29:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C615394000D; Mon, 18 Jul 2022 15:29:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8B8C94000F; Mon, 18 Jul 2022 15:29:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9965294000D for ; Mon, 18 Jul 2022 15:29:01 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7929DE5B for ; Mon, 18 Jul 2022 19:29:01 +0000 (UTC) X-FDA: 79701208482.31.53FC4EC Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by imf13.hostedemail.com (Postfix) with ESMTP id 1730C20095 for ; Mon, 18 Jul 2022 19:29:00 +0000 (UTC) Received: by mail-qv1-f41.google.com with SMTP id m10so5644606qvu.4 for ; Mon, 18 Jul 2022 12:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9jRBPxHetNaAYvNL/Zbk4Gz5JHeIZjINC1YVksHLpK0=; b=UWtmw4bkYSqZCrwkTdXvOJn0HuT45kCRhfcR25N1KZz4XPy5uHeP36ClHVvtxuQ0ml eR5MjNl5qmX49XbhugFRX9Q90pk0oydAsfvrCtMgEq6H+FFLr5M39bqMJV/2aDTL8QMd Mr5FnWMOsu+Oj9iWEBqUquNtUmVGFIUMVcfpkrmO4P1SAV9L6D4GUGE/7pXbBYWmGSvp yCoqENUMPT3+KVmnijAAPfz650MZZj/EIkfrWSELI+A5ssy2P71glhClbjpPNPVxkZHm vYHQO4TP3f3Ii52Sn3fr1U56mheGEatDLvDKTJFdhaq7zhn6Qn+rmyN5Vn2ChEuVs68B RCtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9jRBPxHetNaAYvNL/Zbk4Gz5JHeIZjINC1YVksHLpK0=; b=1zO8Ksr8rMZk5qaal2omerzJe7YnisWOD0tERBVdQ3kJUqkGJeUanZlxcxjrXaQo89 DH6J+5ezFiu61zPKr+jSTK31U4rEr25lJu5D20yY9ZrRi00h/ZerlSQN31hOKzNJ7f3g XWm7HSneNtgFFk7nqId7RBZaaaKJhCbfxq+GPoV927q9UqHYRyLwYxyfkdz0j/qBAZ0c 13uzCIhq/MKheW5jh5nKT97iGEZ3Ko5D7aqYl/cVUlU1hbdYTvQqC/ARFdYbiQCwntlP l7A7lr2WWi3h+E/Nnn7wIvUyXvsxQDXGRaywV/iyDccCxLVrEGs7YTW9ndOcmYMURRLm rMzg== X-Gm-Message-State: AJIora86G2cpazP5zvzSD8q2FSkJIoQj2NZfO9KuS5Ueb/+q+9cTjyLV Ql4fxC8ZG1RXTi3DAKi/zrI= X-Google-Smtp-Source: AGRyM1tJL6xF5uFJZtWlPYKjynWj22iMoR4ixYcMYqU4mAIXJGlgzVLwHxDXYCNM6iwonqEgJ0BPsw== X-Received: by 2002:a05:6214:d8c:b0:473:5a78:cdd3 with SMTP id e12-20020a0562140d8c00b004735a78cdd3mr22081665qve.105.1658172540532; Mon, 18 Jul 2022 12:29:00 -0700 (PDT) Received: from localhost ([2601:4c1:c100:1230:ab01:d009:465a:5ab1]) by smtp.gmail.com with ESMTPSA id y14-20020a37640e000000b006b5869c1525sm11450264qkb.21.2022.07.18.12.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 12:28:59 -0700 (PDT) From: Yury Norov To: linux-kernel@vger.kernel.org, Alexander Lobakin , Alexei Starovoitov , Alexey Klimov , Andrew Morton , Andrii Nakryiko , Andy Shevchenko , Ben Segall , Christoph Lameter , Dan Williams , Daniel Borkmann , Daniel Bristot de Oliveira , Dennis Zhou , Dietmar Eggemann , Eric Dumazet , Frederic Weisbecker , Guenter Roeck , Ingo Molnar , Isabella Basso , John Fastabend , Josh Poimboeuf , Juergen Gross , Juri Lelli , KP Singh , Kees Cook , Martin KaFai Lau , Mel Gorman , Miroslav Benes , Nathan Chancellor , "Paul E . McKenney" , Peter Zijlstra , Randy Dunlap , Rasmus Villemoes , Sebastian Andrzej Siewior , Song Liu , Steven Rostedt , Tejun Heo , Thomas Gleixner , Valentin Schneider , Vincent Guittot , Vlastimil Babka , Yonghong Song , Yury Norov , linux-mm@kvack.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 12/16] time: optimize tick_check_percpu() Date: Mon, 18 Jul 2022 12:28:40 -0700 Message-Id: <20220718192844.1805158-13-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220718192844.1805158-1-yury.norov@gmail.com> References: <20220718192844.1805158-1-yury.norov@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658172541; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9jRBPxHetNaAYvNL/Zbk4Gz5JHeIZjINC1YVksHLpK0=; b=ayckmFnrlQr0yEHPOuCO4TmTbijl6gjXcuglUluqhw2kkajO1tWaa2jinM/FlR1vjJJ6VE XJZ/WKz5JnnEI7jRZGSvjNu9UKPZStVTKtKl3N+efiFZJt+iWni9W/9FXk8y2SvgDHoyo4 d2pJmOHDtTGiFyRZ7lzh87y1m+blkl8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658172541; a=rsa-sha256; cv=none; b=k6Jyaf9wCJC+mKL1j7e8gDRhSAKBMtgSxFl64D0RonKMpJb4Y7572oqTyl4v8Cg+9tuNFM MSfY/F5lGc78MgLpLwdxpWrRcCI3ICAuxgJxDCR0/CJMAlfzbiBD5CnOTqiuik3bpifcGg zeOjAifhAMAjkVs6KRtPMqkjvaeHeFc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UWtmw4bk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.219.41 as permitted sender) smtp.mailfrom=yury.norov@gmail.com X-Stat-Signature: 1hmei7reuoandie565h1zp4s5ox8855h X-Rspamd-Queue-Id: 1730C20095 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UWtmw4bk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of yury.norov@gmail.com designates 209.85.219.41 as permitted sender) smtp.mailfrom=yury.norov@gmail.com X-Rspamd-Server: rspam06 X-HE-Tag: 1658172540-860532 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: tick_check_percpu() calls cpumask_equal() even if curdev->cpumask == cpumask_of(cpu). Fix it. Caught with CONFIG_DEBUG_BITMAP: [ 0.077622] Call trace: [ 0.077637] __bitmap_check_params+0x144/0x250 [ 0.077675] tick_check_replacement+0xac/0x320 [ 0.077716] tick_check_new_device+0x50/0x110 [ 0.077747] clockevents_register_device+0x74/0x1c0 [ 0.077779] dummy_timer_starting_cpu+0x6c/0x80 [ 0.077817] cpuhp_invoke_callback+0x104/0x20c [ 0.077856] cpuhp_invoke_callback_range+0x70/0xf0 [ 0.077890] notify_cpu_starting+0xac/0xcc [ 0.077921] secondary_start_kernel+0xe4/0x154 [ 0.077951] __secondary_switched+0xa0/0xa4 [ 0.077992] ---[ end trace 0000000000000000 ]--- [ 0.078021] b1: ffffbfec4703b890 [ 0.078031] b2: ffffbfec4703b890 [ 0.078043] b3: 0 [ 0.078052] nbits: 256 [ 0.078065] start: 0 [ 0.078075] off: 0 [ 0.078086] Bitmap: parameters check failed [ 0.078095] include/linux/bitmap.h [419]: bitmap_equal Signed-off-by: Yury Norov --- kernel/time/tick-common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c index fdd5ae1a074b..7205f76f8d10 100644 --- a/kernel/time/tick-common.c +++ b/kernel/time/tick-common.c @@ -290,13 +290,15 @@ static bool tick_check_percpu(struct clock_event_device *curdev, { if (!cpumask_test_cpu(cpu, newdev->cpumask)) return false; - if (cpumask_equal(newdev->cpumask, cpumask_of(cpu))) + if (newdev->cpumask == cpumask_of(cpu) || + cpumask_equal(newdev->cpumask, cpumask_of(cpu))) return true; /* Check if irq affinity can be set */ if (newdev->irq >= 0 && !irq_can_set_affinity(newdev->irq)) return false; /* Prefer an existing cpu local device */ - if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu))) + if (curdev && (curdev->cpumask == cpumask_of(cpu) || + cpumask_equal(curdev->cpumask, cpumask_of(cpu)))) return false; return true; }