From nobody Sat Oct 4 15:57:14 2025 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73F9123BF9F for ; Thu, 14 Aug 2025 19:09:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755198585; cv=none; b=C76eYJhusy2drQ4X4HZuKdiNJONerpJFwkB/0k597fYQWfPYngUn71fyOtnCxf8aoUrvB8+AcrRc1mLH+yv9MJC4PGgzysxjpi1xemfWRDZ0PXxeFcqmG9YEK8aDdQIaR/QfEj5lHFmSe328EXdCj+X90Z8xLhfEtizRT0zhbs4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755198585; c=relaxed/simple; bh=9vjba/mrt50wb2uoF0SJyRNQncK2P36FFetzGdlbA4c=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GW4xWkhxDm9q5sAO87mBSsLI7qyU9HNRlJqFUkvrqrtUB/ufjqPjuQLbVKF8ZK+Jpy91GXu8CC0ap2Xa1Fu2BRW+w84MAMz7VRsC0c/t+HIQdEMm3/p/DoDXrS2Gs0VYiEhbf1vguRjPkvx24cNtdgzXo3F+UtviqP7nYiEyH6E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T4lxg67f; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T4lxg67f" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-323266d74b0so1193935a91.0 for ; Thu, 14 Aug 2025 12:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755198583; x=1755803383; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+UJlJ9+DjZd2THGL3J+lidGXBes5gAiTYGr+fy//EDg=; b=T4lxg67fVaI7Sr97IfmvlZzC1Znb45BAfQ+OgYXf5tNLeeGPWGARuwXgl/FaznM/50 392yAPZ8bCHGaSiHK++XyrMKCZnVkPtJqs2OBDmALnkexd2wyX5mGvk0LmIrxr44bGfj RTFkiCfhZEzgOG0Z4pQUagB07YpnPmJQKn3z5hpa5SAdanR00umdrdMPp5WalwcOfqZK 2B1vg9dMIvvQJ92kneY6JtV/suLqCftA9gWMKxq5MDLhsms8+y2mwcSarVR9KHcebF2B Mi1yd+wgqMjqFVTo0Mxbi6XuAJhNlUFH2C/i/oF1Z13aKizonkj1Aa8hLq4l+Dt/s8nR YdoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755198583; x=1755803383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+UJlJ9+DjZd2THGL3J+lidGXBes5gAiTYGr+fy//EDg=; b=JzPUNDWXhsxtLzSN8uB5ET7E9SHzOQ1KguGj6ZMbbw5vU0Cgg0/+bHyk8ueMugJ4o2 BB25a54iI/qju1uGML19973c1PCII3o6IYrwujFsUzNk7sekDypTxc/0GEUKXCmhvNld TxTkuRm4N2KroNQWnmFieJuXRJsfeOd09EJYZoa07pNh61q5DZqu0862m6MOIyugspMV ItLuXY5R9wnQQeqOCXMNcMYJSiL7LhRDHNNQPHgnNN8Ow2JvuU9Xjvku46NqeU9xHZQ9 D1Vzg8+aPWGFFwbDzcB5UZkwamvzzVz25vaKvwxaL/JfwFBIFUrEnaG5sMNNICOW6lWj eFsw== X-Forwarded-Encrypted: i=1; AJvYcCXtf8k36oVWKqdLCWjEkv7yNCndbhPY4zFbWzJ3o4YqfAEHtxgodbVzBtISxAxuT/WwNRCwdJdMbFokCDI=@vger.kernel.org X-Gm-Message-State: AOJu0YxWHn7UQuxsWFdbcrvNoopaDkpgpPV2yaif6he2dqXtDoLBGhY6 NkYY+8OyMnz07TCICzwUfAVkdthmKcagNDUFsasVM/4DXc4lVW39/4U+ X-Gm-Gg: ASbGncvfbS5gm+MZXai9P/2N7VQS2YaRZDLAS4fZHb7OPFgpb5Pj3un28XPGBmDdUhR 4EihV6XYMBjrmt/vZM/NxWGlUGqyZzFIpqgv/6gV0Q2ixM97HSMKLJvmJjOFLs63ihb7gh7ddFp WotZ4LvuIiX69Fh9XtuhfVZgxtxHKOTDtiAV8k+w7BfsOgplhd5uKCcWpUIRW6/WQDgztTkgFs3 2NyIrI13A9uJWULRb/ea8YqdpAseR8lDpYmDOEeHJKvq6t5o6TfSBrakRnUFw06dNjvEbHcUUoh FkmfrK0lDOQOn3EQg4bp0JXi4dLZGsAhR5tdlpJnrnAs+Spow78dJZi7fbopB2hnAf4+XKG2Hth 9Uwyj+iaTCYL0MsIf8U6m+g== X-Google-Smtp-Source: AGHT+IFFwZv1c1ZK8S3HgX4X3suV9YEHMQS8EnvLEjc+VXrDDUDebFYY3z9RLaiGqd94M4QhyksWTw== X-Received: by 2002:a17:90b:3c86:b0:321:1df6:97d3 with SMTP id 98e67ed59e1d1-3233d09ce8fmr24505a91.4.1755198583280; Thu, 14 Aug 2025 12:09:43 -0700 (PDT) Received: from localhost ([216.228.127.131]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-32330f8329asm2637497a91.3.2025.08.14.12.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 12:09:42 -0700 (PDT) From: Yury Norov To: "Jiri Slaby (SUSE)" , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Thomas Gleixner , Frederic Barrat , Andrew Donnellan , Yury Norov , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] powerpc: pci-ioda: use bitmap_alloc() in pnv_ioda_pick_m64_pe() Date: Thu, 14 Aug 2025 15:09:35 -0400 Message-ID: <20250814190936.381346-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814190936.381346-1-yury.norov@gmail.com> References: <20250814190936.381346-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Yury Norov (NVIDIA)" Use the dedicated bitmap_alloc() in pnv_ioda_pick_m64_pe() and drop some housekeeping code. Because pe_alloc is local, annotate it with __free() and get rid of the explicit kfree() calls. Suggested-by: Jiri Slaby Signed-off-by: Yury Norov (NVIDIA) --- arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platf= orms/powernv/pci-ioda.c index d8ccf2c9b98a..2a4b916205c1 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -292,18 +292,16 @@ static void pnv_ioda_reserve_m64_pe(struct pci_bus *b= us, =20 static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool = all) { + unsigned long *pe_alloc __free(bitmap) =3D NULL; struct pnv_phb *phb =3D pci_bus_to_pnvhb(bus); struct pnv_ioda_pe *master_pe, *pe; - unsigned long size, *pe_alloc; int i; =20 /* Root bus shouldn't use M64 */ if (pci_is_root_bus(bus)) return NULL; =20 - /* Allocate bitmap */ - size =3D ALIGN(phb->ioda.total_pe_num / 8, sizeof(unsigned long)); - pe_alloc =3D kzalloc(size, GFP_KERNEL); + pe_alloc =3D bitmap_zalloc(phb->ioda.total_pe_num, GFP_KERNEL); if (!pe_alloc) { pr_warn("%s: Out of memory !\n", __func__); @@ -319,7 +317,6 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct = pci_bus *bus, bool all) * pick M64 dependent PE#. */ if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) { - kfree(pe_alloc); return NULL; } =20 @@ -345,7 +342,6 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct = pci_bus *bus, bool all) } } =20 - kfree(pe_alloc); return master_pe; } =20 --=20 2.43.0 From nobody Sat Oct 4 15:57:14 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DA3B23D7D9 for ; Thu, 14 Aug 2025 19:09:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755198588; cv=none; b=K5iEWLB1upzB+YPqiznr8E3kcu1SDAWj4Dh9q0gJPejZb26U6codmH/1KJR33G1JPe75cgIbQe79MY/TU08k4D9ul5qyO5f/cnZLhLLtk0+W/90xAqT9rzRzQ4AIGHZaQHF8Lo9KEjwIR7J23Wz4ONxWFwZW53S7FuTq4nIqKN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755198588; c=relaxed/simple; bh=cn8UvPsPJD/j/9nIZcPS6rcqmeIlHdPR+kakUIbdYLI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lVWeo+0E+/x2U+panLEqE2UQ9djsQ3fLSswGSq+rQT8/HAVE37JxwPF2DD04D1U9X/C3TyfJnSjKZhyJfgSAkAJJ+0Fl8NS/VD6Jjsw+K2HBN7ZPfWC9dfqqVh+xIsYqVmJgs/10TP9ZNzNCHrp3q/6c4g2dodKRvr3ROnYh9DE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nctA3LNH; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nctA3LNH" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-76e2e89e89fso1770529b3a.1 for ; Thu, 14 Aug 2025 12:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755198586; x=1755803386; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=IF8qj3lRR6EFkcmgoXgDdUEvoMakOzSl+hSokVwaKUI=; b=nctA3LNHtxKxc1torIE6n+BuhpiXsecc4+rnik6Ldu1Ced5wWz30xAe7wN0dryZwG4 v9gakz5G+9BLa470AEspTQa+6eNeaqG/XszHZzpluj2rBmlbDTcIDNxroFshg3QSh9Cv XFgt9kZ4WA66CvRda6UicHnRpYBhJYU8MNZ555s9ArqwY7tfTST4+UXp4QkXo/MOLS5O 9wZabiFTY6qkqryeQHVZXjAygfsdkstBiwC8/JUwuHhYyXGXw/H2zJxc3nZIr7HfPUzS i1V8BB8CrGcrsEYI52iBBVowPHb1W7YEjRUIDxKQiN56ogx1I+wQUhbxcN3jDW6mWA4M j0ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755198586; x=1755803386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IF8qj3lRR6EFkcmgoXgDdUEvoMakOzSl+hSokVwaKUI=; b=PqGRpuNSllKmQhNS28rk/IuSf/dLdAgoeGo/oHwOoxlqMPmPyUyrxX/7Oa9GKlivPe fwZPpCnbJaupEs/5aGGMhKKGoEiP9BkmoaU3+0WpNelvVA9WYThhqM1AIUqig1itIFlD +v8R4OJTLM3meAxF6DoI38U1fZaxwN+5T5JXc7/mZj+K63dThRxNVxZchxCy5PlDvxoI qfQ7LvMOW2onRt4DanRXQkz9NXxpTeHBVhyywh3nhBkoADou8rXs5FYJV0L2MD+1ZbEt ZF0unCupYXWJLRhmojmAr34CEp5h9VoAwF4ViXgXs+T8Til08wFZnV7JQVgariOd7Arz VCpQ== X-Forwarded-Encrypted: i=1; AJvYcCVl4imbO5RnQgnFUrRWZ1kH7d8NLG8OfCrIXWZ9anqh4jbd38fbDHhBI/wHIyHf5zlH7SRtuQliKyZ+X28=@vger.kernel.org X-Gm-Message-State: AOJu0YzrQVsp07pBphEBbJhKEv+MZ7wQ6RfQiJyw6/MuRsGJck4oyhVo Mcg737QuW9ELW8b3ZDaCMixy/fGznyL1voDTKttGLhoXsNPP6vsJZRoB X-Gm-Gg: ASbGncvNfG6nNAYVHeec7/nfC6ImYknO08Vf65IDsfoWEDe8ADrAkvC+KFT/WM2j9es KMmO5zhrK/8UUCKhPVP4WaP4BOcgncZDVuShgKdh6UBK86PgdiekqCDlbGUWjGhgDh2ya3W66Du 1JIINp3YhjDUQEvFsakvo3aL9IeUYHgaW7VbpoQnpOf3XRQlK/djDxPlCTi1Duj7YvDhC3RVAdU e6s6lwpKNVnj+L5g2mWjqJShXnQM8z7gap1s2iO6yjpw9Onuv/dDk5eKVsnUhtxHBl/OfY0coQj yk2kURn4JYB4fif+Kkwl/7OjXkPxde/bjBjgYApIZFaq1ueA7WMxqwHKGRFICZ4oYj34ULP9VeV xmwgX+h2enrRp3B4S/pawTA== X-Google-Smtp-Source: AGHT+IHO9E6Ju6YUC/4W76OL34pJ6YJlwPdxgruOXLM17Ydpcq6OMMHw8A2vXRvcEHPm1CQnzcq1PQ== X-Received: by 2002:a05:6a20:5491:b0:240:104c:8e14 with SMTP id adf61e73a8af0-240bd285526mr7187108637.38.1755198586198; Thu, 14 Aug 2025 12:09:46 -0700 (PDT) Received: from localhost ([216.228.127.131]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bccfd8ebbsm35345257b3a.102.2025.08.14.12.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 12:09:45 -0700 (PDT) From: Yury Norov To: "Jiri Slaby (SUSE)" , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Thomas Gleixner , Frederic Barrat , Andrew Donnellan , Yury Norov , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] powerpc: pci-ioda: Optimize pnv_ioda_pick_m64_pe() Date: Thu, 14 Aug 2025 15:09:36 -0400 Message-ID: <20250814190936.381346-3-yury.norov@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250814190936.381346-1-yury.norov@gmail.com> References: <20250814190936.381346-1-yury.norov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Yury Norov (NVIDIA)" bitmap_empty() in pnv_ioda_pick_m64_pe() is O(N) and useless because the following find_next_bit() does the same work. Drop it, and while there replace a while() loop with the dedicated for_each_set_bit(). Reviewed-by: Andrew Donnellan Signed-off-by: Yury Norov (NVIDIA) --- arch/powerpc/platforms/powernv/pci-ioda.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platf= orms/powernv/pci-ioda.c index 2a4b916205c1..23b1db3f15a9 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -295,7 +295,7 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct = pci_bus *bus, bool all) unsigned long *pe_alloc __free(bitmap) =3D NULL; struct pnv_phb *phb =3D pci_bus_to_pnvhb(bus); struct pnv_ioda_pe *master_pe, *pe; - int i; + unsigned int i; =20 /* Root bus shouldn't use M64 */ if (pci_is_root_bus(bus)) @@ -311,23 +311,16 @@ static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struc= t pci_bus *bus, bool all) /* Figure out reserved PE numbers by the PE */ pnv_ioda_reserve_m64_pe(bus, pe_alloc, all); =20 - /* - * the current bus might not own M64 window and that's all - * contributed by its child buses. For the case, we needn't - * pick M64 dependent PE#. - */ - if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) { - return NULL; - } - /* * Figure out the master PE and put all slave PEs to master * PE's list to form compound PE. + * + * The current bus might not own M64 window and that's all + * contributed by its child buses. For the case, we needn't + * pick M64 dependent PE#. */ master_pe =3D NULL; - i =3D -1; - while ((i =3D find_next_bit(pe_alloc, phb->ioda.total_pe_num, i + 1)) < - phb->ioda.total_pe_num) { + for_each_set_bit(i, pe_alloc, phb->ioda.total_pe_num) { pe =3D &phb->ioda.pe_array[i]; =20 phb->ioda.m64_segmap[pe->pe_number] =3D pe->pe_number; --=20 2.43.0