Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp8917394ioo; Sat, 4 Jun 2022 23:43:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxq0oA08/20xTN62MLlyY7Dbwatoo+gLTswPVZbyMKwk6fc0f2jSM203HhgJsLewu9eYFk3 X-Received: by 2002:a17:903:124a:b0:154:c7a4:9375 with SMTP id u10-20020a170903124a00b00154c7a49375mr18188317plh.0.1654411434960; Sat, 04 Jun 2022 23:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654411434; cv=none; d=google.com; s=arc-20160816; b=iJdvOpbkXZBfYLYPG2yW9cfCc/Kk9haY7NbYEnQLdFd0Z1jg/DhOYuUNk0xdlXUs6G DSloOY03QzAE7W8pzf1yZ6aM1Xq6tWZbUH8H6iirWPXPFfo9x7pEFxmLmriOdB9VcNhm bh6P1nOcFGYXUik9vjpo7gXVbHWXU/0/gomCtxmFXdybYcdCy6ZkYCADBVGfLjlCDV+c hqDz3PeYNB9soDo9heeCCU2IAsq9BXttkepEFwRbJ8VyROY09h2w+sxamd6XKSOnDo8c LA2wlJ1hCDbfJpJqZduCu0dn5TbqtVGmIO+9V7R+O5Kkss52qZEE6YkQuK+y5bJy9lq+ Xd1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3e8JObibZ7sZMHKEhLJjFgEiHdbc/1Vf54b/PRl3NHE=; b=YRX27fxJV+QPO1P63HEra3T/CcWuIUgUEPidEukJOAvQ9gk3HOl7mgljeCPGX0W507 Q6tlncq3+kSw/iSeEm9NV/LbqeENJLrO4bbP/AWlkwWAkRj3mZjaTYSvlC3Z2inx9zLi 1+zpa31t7UJ7zwROoZbygcoHYqlqGgUnVRBH0RL3TtFzxZSX+K3VsvkqlQoQUhFWfbeo LXqUSbJBOv2vqDyMSQBBa4/LdxkhrYa4ApFW0ndTLPMdGZIuY9SvQI7Y6i/qCpjejXfK UJIDfT6V75c3i0K/lnC6CGdyXs/hR4+0bP8mbtmp95B1gvQf+e140PBpGuhMS/YxXhTf WBbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svanheule.net header.s=mail1707 header.b=eYgxVOlX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svanheule.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a17090332c200b001640aa6d40bsi18580090plr.79.2022.06.04.23.43.39; Sat, 04 Jun 2022 23:43:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@svanheule.net header.s=mail1707 header.b=eYgxVOlX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svanheule.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244339AbiFEGWy (ORCPT + 99 others); Sun, 5 Jun 2022 02:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbiFEGWw (ORCPT ); Sun, 5 Jun 2022 02:22:52 -0400 Received: from polaris.svanheule.net (polaris.svanheule.net [IPv6:2a00:c98:2060:a004:1::200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1A6013D56 for ; Sat, 4 Jun 2022 23:22:49 -0700 (PDT) Received: from terra.. (unknown [IPv6:2a02:a03f:eaf9:8401:aa9f:5d01:1b2a:e3cd]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id 8C53A2E2DA1; Sun, 5 Jun 2022 08:22:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1654410166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3e8JObibZ7sZMHKEhLJjFgEiHdbc/1Vf54b/PRl3NHE=; b=eYgxVOlXJdz/3eRW/Yqfr5I3U7xULEh1fG3tiXymOG+dlZmz6S9ecsqQpxV+J0e/Gr/8fU 8Qt4UzcOtI7a5dM5rKUyM6eYMb2o6G5CLHZl3f9iAmaSY6k+unXd6fOcYVc45UrYM7naKl jN+6IxibQSFJMOSDU2lrMLr+ZzkzNCM28xrzQiKbwz8MzM648a7KNgq7ryz+nSHAK5xVDD XTsvf4N/DJCSog44kDHtVcUmDXPd+wPbB58PkmULKUSdS/oTn9BDiIRcERX1MfZlOJbqbG BjRSP/Wf77onappYvJe9hwh/f7UeUcheJWCZ1av3QAj7zjhP1hCbvGs9QJK7Xw== From: Sander Vanheule To: Peter Zijlstra , Yury Norov , Andrew Morton , Valentin Schneider , Thomas Gleixner , Greg Kroah-Hartman , Marco Elver Cc: linux-kernel@vger.kernel.org, Andy Shevchenko , Sander Vanheule Subject: [PATCH v3 0/4] cpumask: Fix invalid uniprocessor assumptions Date: Sun, 5 Jun 2022 08:22:37 +0200 Message-Id: X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On uniprocessor builds, it is currently assumed that any cpumask will contain the single CPU: cpu0. This assumption is used to provide optimised implementations. The current assumption also appears to be wrong, by ignoring the fact that users can provide empty cpumask-s. This can result in bugs as explained in [1]. This series introduces some basic tests, and updates the optimisations for uniprocessor builds. [1] https://lore.kernel.org/all/20220530082552.46113-1-sander@svanheule.net/ Changes since v2: Link: https://lore.kernel.org/all/cover.1654362935.git.sander@svanheule.net/ - Put new tests after patch fixes - Update for_each_* macros Changes since v1: Link: https://lore.kernel.org/all/cover.1654201862.git.sander@svanheule.net/ - Place tests in lib/test_cpumask.c - Drop the modified UP code in favor of the generic SMP implementation - Update declaration of cpumask_next_wrap() Sander Vanheule (4): cpumask: Fix invalid uniprocessor mask assumption lib/test: Introduce cpumask KUnit test suite cpumask: Add UP optimised for_each_*_cpu versions cpumask: Update cpumask_next_wrap() signature include/linux/cpumask.h | 89 +++------------------------ lib/Kconfig.debug | 9 +++ lib/Makefile | 4 +- lib/test_cpumask.c | 132 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 151 insertions(+), 83 deletions(-) create mode 100644 lib/test_cpumask.c -- 2.36.1