Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1925650rdb; Thu, 7 Dec 2023 12:39:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKb77gdCAWkELoFtury1/Zh4O6X1bHSaa9cRnrFhgAfFNpyFt0u+PQgu2a1+LuVQ8UaVSt X-Received: by 2002:a05:6a00:181b:b0:6ce:2ec8:2ec8 with SMTP id y27-20020a056a00181b00b006ce2ec82ec8mr3447020pfa.37.1701981555294; Thu, 07 Dec 2023 12:39:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701981555; cv=none; d=google.com; s=arc-20160816; b=fRXb6VIJPh2Oxd+Fv2+W9pbGD5o4QGujc6mIRPmjjVwDCreE9W1RU7TSQtczZyfc0I rZVdCoNZbKZ/vQcmuFSPvhUco3RQSHtZI2ZBVq0LUvaZZMHKlthXXbXucPnWyTnzpWxo UNKdny+ZHFxGJ7fTzq3A1R9CLoEbUETpImFiJG5yUg7675zmEuItj8Nv1XIVPeZUUVfE NJ0FhqzsaC6crPcfcVXBe/DIy4UbwTI4GtmxiGgSIRuoZiNUi9Yh+GUDxBf7iogOcwsd tgV9ZcCg+Pr++dnLdVbP2O7Px4KqNOCjFK/i7rgyeoGrXaZiexEJ5vis3gAUnu0pX4gQ JGMQ== 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=f0nqkFu7e/a89gcQ+5bKDtMmMoDf4cXbjeDawa75MYo=; fh=1BoNDGd05aaAMfPxVJ9+hJFzTAErL73yhXGdigwpwQY=; b=ybdkvFdE8M3cqCI+Gw2QvPl6SMAwb36qPzPQnrEQp0fi11wFIMF45d3RwdRIchNHgC Z1DJZSjHkcQ+YIgsHSSRkCiJtdKoSxQ59s9WwKVGgjpnDiFmMzhvt/wdJJYCDEFxizgY l9UIJrs2Hpddum6dspe4+E0XGIytOcYQUsNGOG8j2DnnunAKk1Vbyo9muIQWzZqtVohq UtbM5h2SSDbeY5uWlDOHPItJoLa273mkdnXpjLpbLLmOuTxJTN/KomKfMs8vfhFMS8MU cZ3+bwDqgxlkqQaKtgde/k7zEcj2qYkHerSzeYhi2e14YXWFWO7FuCKBMs3ZPeB+p/Vd yMNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="k8DXPu/a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id y190-20020a6364c7000000b005c60319034bsi239756pgb.481.2023.12.07.12.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 12:39:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="k8DXPu/a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CF48680D6A0C; Thu, 7 Dec 2023 12:39:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbjLGUi6 (ORCPT + 99 others); Thu, 7 Dec 2023 15:38:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjLGUi4 (ORCPT ); Thu, 7 Dec 2023 15:38:56 -0500 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D2631713 for ; Thu, 7 Dec 2023 12:39:03 -0800 (PST) Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-db4364ecd6aso1437567276.2 for ; Thu, 07 Dec 2023 12:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701981542; x=1702586342; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=f0nqkFu7e/a89gcQ+5bKDtMmMoDf4cXbjeDawa75MYo=; b=k8DXPu/a47RcjSNVg6zJu4tQtfglRyieZSADUTSV3apRwl7NArYMXEsVXtG+vyqtK1 9IOoqSNgcFhqVLcS98QLbbfWNUw9eGd1biry/0pc7M7Zucy1+QlbD8qXo0LzCs37mBMG /keBWrhUCHfshacS4O4azIFZ3uQsrSQwovLgDycmVkqH+mo2zqXeVtuNKLXPmo6ixv3D 4QyEs6PjERiQY6enw1kRSbgSS2YNA+enTeVh1Vac554qVjrNR1cyCcZKSOcSxn9I15QI oyNPQYAPIEw7KE/suEKNIzaAeI5jIrjqV4uUZ5UjInn7FQ2FIenkfsZKbu3dRPUxMDBt voUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701981542; x=1702586342; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f0nqkFu7e/a89gcQ+5bKDtMmMoDf4cXbjeDawa75MYo=; b=PGX6nuW1G0OQS06pK1RDBBhl1J9ZaXyDXGVdNu6UV5wPXLQNKGGliaNa0mwvOujF3O Jm5g1V/A78I9JyL24yRj9CwQ8bj1GtOmEOI1s+8yeVJoksLzMXPKj4YHDC6CLXJ1PqAc WGfSM7dMisSZKKy9CSG4+fxiOvfoJwTnNZXvWjM2lRnB3fC7v8f85DUXsITfrfEq/g83 V71RtO5LqX7i8NdSCAh73lhHDR1tJ3Us5DXQTvGwA53fGqRpgJX/s5nlqRENg41htG2S CFAxZzX37YDPK4qeIIdxIpwSSkI30hnCFPTYs0hjxlcx+Zp2j0pFGPbeV0r4Cjm5olaD 0mCA== X-Gm-Message-State: AOJu0YwAPO1dusjXEUVxy2od06rU5/HESqL5NCEK3VNriT9p0WSPIDiS OkTrbSDT2eTn0JmTX/X7ei4= X-Received: by 2002:a25:2541:0:b0:db7:6630:be4b with SMTP id l62-20020a252541000000b00db76630be4bmr2235384ybl.55.1701981542488; Thu, 07 Dec 2023 12:39:02 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:8f7f:efcd:5388:af4f]) by smtp.gmail.com with ESMTPSA id e82-20020a25e755000000b00d9ab86bdaffsm146662ybh.12.2023.12.07.12.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 12:39:02 -0800 (PST) From: Yury Norov To: Andrew Morton , Thomas Gleixner , linux-kernel@vger.kernel.org Cc: Yury Norov , Ming Lei , Andy Shevchenko , Rasmus Villemoes Subject: [PATCH v2 0/6] lib/group_cpus: rework grp_spread_init_one() and make it O(1) Date: Thu, 7 Dec 2023 12:38:54 -0800 Message-Id: <20231207203900.859776-1-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 07 Dec 2023 12:39:13 -0800 (PST) grp_spread_init_one() implementation is sub-optimal because it traverses bitmaps from the beginning, instead of picking from the previous iteration. Fix it and use find_bit API where appropriate. While here, optimize cpumasks allocation and drop unneeded cpumask_empty() call. --- v1: https://lore.kernel.org/all/ZW5MI3rKQueLM0Bz@yury-ThinkPad/T/ v2: add few more optimizations (patches 5-6) Yury Norov (6): cpumask: introduce for_each_cpu_and_from() lib/group_cpus: relax atomicity requirement in grp_spread_init_one() lib/group_cpus: optimize inner loop in grp_spread_init_one() lib/group_cpus: optimize outer loop in grp_spread_init_one() lib/cgroup_cpus.c: don't zero cpumasks in group_cpus_evenly() on allocation lib/group_cpus.c: drop unneeded cpumask_empty() call in __group_cpus_evenly() include/linux/cpumask.h | 11 ++++++++++ include/linux/find.h | 3 +++ lib/group_cpus.c | 47 +++++++++++++++++++---------------------- 3 files changed, 36 insertions(+), 25 deletions(-) -- 2.40.1