From patchwork Mon Jul 18 19:28:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 12921640 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42CA4CCA481 for ; Mon, 18 Jul 2022 19:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234480AbiGRT2x (ORCPT ); Mon, 18 Jul 2022 15:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235605AbiGRT2u (ORCPT ); Mon, 18 Jul 2022 15:28:50 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FE1AD5A; Mon, 18 Jul 2022 12:28:48 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id r21so8832283qtn.11; Mon, 18 Jul 2022 12:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=OWEXlSbAfAwywlnXDil6CYNW0FSVu9hGAT+NA18MHDQ=; b=EdkRpor4TlGyKnTLZL6ybUgdj9y+RP1U2qMx+qo2WRbae6kczgkFok4CRrhKnmECjE BkNDZq/325XPSSByV3oQf/TzCJs5c0+pyMopjHMn+DloZPH4YCia6agETBzkZ9O2R63r Sfzc43oRP8KkOnmqDB65zJIgv4o3qXdvG+V6aFbNWCQKf1EsDN37x+1WeR3Nt4oMt769 2KPNHOqvnz2G/wmJSU5SWhdVktHz7N8FZU6k1/q5lT1ljCiNPCjqMSlIUzNrNatzQ0XQ lFN5p4uVklAw74PmFXTeVo1V90esQebTmWviZEGmWjkKyWhJEsnO56dg/6lR7uMiRsY9 6e6w== 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:mime-version :content-transfer-encoding; bh=OWEXlSbAfAwywlnXDil6CYNW0FSVu9hGAT+NA18MHDQ=; b=xNIInG5c2bWBb6+jh8vjLB9TXOaFJCqOShYcUtaShzC8kNkCVfSUZYaF6EWt0mEpCC FGxgi09S3hWEKX9/1Y+g7eiZgVDeDBBV+CcSTpQeqcuZO6lyaF26Z5LhS1lprb5InFcS MtvUaaUkR92xJCSM+JpK/WcMp6p6gEnH2DviyJQkST0W+6rNfIp4ULcMILLmXNdniGCw cMrP4NcaG6kY4oqW+wipyyVf2hBu1G/pf+DwtOh6Le3ZEbSxTlGRGOJpzsfZzvM7AFBp S1mJ4ZoMh5i5AylPXKBxbBPqvQfQXjgtccovPYqQkL3zQYkvpHxQU2K+NecEzMBrA24C lQPQ== X-Gm-Message-State: AJIora+87SjU8KiEY+5e8rwMGYuXoOXaOg8241qpdvaEzeDKgTKVxTSB SI7WBLAszBuvethKqyyYkdSTeZYYNxLkbg== X-Google-Smtp-Source: AGRyM1vqDidU2mj3mjL1nyFt/o9b/6DrRe9boOZKOh5cfsbupafmIWKyPwSd3R9NQ0P+as9cY9uNww== X-Received: by 2002:a05:622a:58d:b0:317:ca0d:91a5 with SMTP id c13-20020a05622a058d00b00317ca0d91a5mr21815757qtb.601.1658172526705; Mon, 18 Jul 2022 12:28:46 -0700 (PDT) Received: from localhost ([2601:4c1:c100:1230:ab01:d009:465a:5ab1]) by smtp.gmail.com with ESMTPSA id q9-20020ac84509000000b0031eb3af3ffesm9650206qtn.52.2022.07.18.12.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 12:28:46 -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 00/16] Introduce DEBUG_BITMAP config option and bitmap_check_params() Date: Mon, 18 Jul 2022 12:28:28 -0700 Message-Id: <20220718192844.1805158-1-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Bitmap functions are often a part of hot paths, and we can't put argument sanity checks inside them. Sometimes wrong parameters combination cause bug reports that are pretty hard to investigate: https://lore.kernel.org/linux-mm/YsbpTNmDaam8pl+f@xsang-OptiPlex-9020/ And sometimes we can optimize caller code. For example, to avoid copying of bitmap if source and destination are the same. It's quite tricky to detect such places unless we've covered all bitmap API calls with the parameters checker. This series: - introduces bitmap_check_params() with a couple of common-used wrappers; - clears all bitmap warnings found for x86_64, arm64 and powerpc64 in boot test. Yury Norov (16): lib/bitmap: add bitmap_check_params() lib/bitmap: don't call bitmap_set() with len == 0 lib/test_bitmap: don't test bitmap_set if nbits == 0 lib/test_bitmap: test test_bitmap_arr{32,64} starting from nbits == 1 lib/test_bitmap: disable compile-time test if DEBUG_BITMAP() is enabled lib/test_bitmap: delete meaningless test for bitmap_cut smp: optimize smp_call_function_many_cond() smp: optimize smp_call_function_many_cond() for more irq: don't copy cpu affinity mask if source is equal to destination sched: optimize __set_cpus_allowed_ptr_locked() time: optimize tick_check_preferred() time: optimize tick_check_percpu() time: optimize tick_setup_device() mm/percpu: optimize pcpu_alloc_area() sched/topology: optimize topology_span_sane() lib: create CONFIG_DEBUG_BITMAP parameter include/linux/bitmap.h | 95 +++++++++++++++++++++++++++ kernel/irq/manage.c | 3 +- kernel/sched/core.c | 3 +- kernel/sched/topology.c | 10 ++- kernel/smp.c | 35 ++++++++-- kernel/time/tick-common.c | 18 ++++-- lib/Kconfig.debug | 7 ++ lib/bitmap.c | 132 ++++++++++++++++++++++++++++++++++---- lib/test_bitmap.c | 12 ++-- mm/percpu.c | 3 +- 10 files changed, 281 insertions(+), 37 deletions(-)