Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2285355pxb; Sun, 30 Jan 2022 10:44:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEgLKK45TkdXnDUSDmkxv4M7fM5Dx0OnnJFHGrlUZnjp3TkGURk9hUvMHkWm57QpLc2Cs6 X-Received: by 2002:a17:902:c206:: with SMTP id 6mr18155060pll.46.1643568242909; Sun, 30 Jan 2022 10:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643568242; cv=none; d=google.com; s=arc-20160816; b=Cd/hnmQ+0jmk7/ucw30JpAi92KC/txpt1C6FuBOkdBb9MsgBOvuiKkwPApJ0vHSw9A jlOwucYVC41ZfRbJ453UiTgH6wsByZ4QlMJjGvSdcAVATWCPR2EcVKBmueXkTPJn9r4q MYqyfqjNWHtNQOotTexySCxSRyWHzf0fH8MlP1pRPy1ZXamkhoMTR38l4SsAseOQDlkr nTPOojm2YsrGGC80gzd0FTJKv2UhC+uk2QzvLt+JEQhdEzJme8RmoZvhtmJAMGV/HlNN bu6MAJAf150wXJLIgcnC2vwV4P/UExSDHAIdf/nU/aM7Otr5czu/gcD1Cu9ee9jehWro zU0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=uy2MrDkccIj156ALaICyk+fvYR4qhgIfiYRgdsCeDKk=; b=znMWGOSAqy2PMOFfC7X3cWlze/H82hQHqRGx1MamgAYRlCxUeKvb5vtsZm7dWfLJnm 5+kIGMfkapj6j0zF2fT86RuSyKFqvmBM7YgqDGzws9BVRtNeW+yvdUacpE6iIaVfK5G9 OH/L8xcQCIQ2hhqYN/uioernlOixiohMPRVn01fzIB0TmythkmEaoiHJL2eqHYyOuUlG SLXTT9TsXsLZf01GwyXNgMHnMKP/IE/zZ7N/3xYZeqN3rCeEWFOv1D6e0FuMDTUvxFna XZ/xtN1X/iiZPWW6uYnXC7HiAtxQhY6gyr9fj4QRSFgekxrWf0JiUKebhZTs4fVRrSpB Xihg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e32si11522055pgb.614.2022.01.30.10.43.15; Sun, 30 Jan 2022 10:44:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243189AbiA1Izm (ORCPT + 99 others); Fri, 28 Jan 2022 03:55:42 -0500 Received: from mail-vs1-f54.google.com ([209.85.217.54]:46835 "EHLO mail-vs1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbiA1Izl (ORCPT ); Fri, 28 Jan 2022 03:55:41 -0500 Received: by mail-vs1-f54.google.com with SMTP id u14so2164229vsg.13; Fri, 28 Jan 2022 00:55:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uy2MrDkccIj156ALaICyk+fvYR4qhgIfiYRgdsCeDKk=; b=DBF/s0H3OlBr/RVXCVw7KWjgDNdi0fY2a4gi/La2oZqYBCtvPqeP6CJXMSsOpI3X5i 7MpeJXw1tvJcg1178txTmnFuYsPuJU7uq6SaQbal7JENdkDkKsj8iw6T1hOgnQv8ka2d tXeLREhT30I8T4QEHt1EgPyuxmcjxYknVL1JkBBt1L/EfH2imEtQx9e6iGWTCaaB/cSS RaM3btBABb8Z7TgF2yfSkd4TjGeqtszm4DIg53ShSgnEwbmGsrua9okHKZZxRilRI/Lf n2LDdxfELE5c3sBhlGxX0x52nQiU87Bazmhh7bJpHL5bycW8GNBUQZV/8u3P0T6HJZBH ukOQ== X-Gm-Message-State: AOAM531+CqWX/27iaHEHR3fycJVO19vKRIoEHcq+UsF2lidbbw5AMpZ/ kOMp5p1e6r01jpjVDBEC64SF8Vfya9lQDDF5 X-Received: by 2002:a67:cb87:: with SMTP id h7mr3518145vsl.67.1643360141032; Fri, 28 Jan 2022 00:55:41 -0800 (PST) Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com. [209.85.217.51]) by smtp.gmail.com with ESMTPSA id r11sm2073140uaw.7.2022.01.28.00.55.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jan 2022 00:55:40 -0800 (PST) Received: by mail-vs1-f51.google.com with SMTP id v62so2171505vsv.4; Fri, 28 Jan 2022 00:55:39 -0800 (PST) X-Received: by 2002:a67:a401:: with SMTP id n1mr3329515vse.38.1643360139371; Fri, 28 Jan 2022 00:55:39 -0800 (PST) MIME-Version: 1.0 References: <20220120090918.2646626-1-atishp@rivosinc.com> <20220120090918.2646626-7-atishp@rivosinc.com> <1AA3005C-E9C8-4E4B-900D-DD48B37CEA41@jrtc27.com> In-Reply-To: From: Geert Uytterhoeven Date: Fri, 28 Jan 2022 09:55:28 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 6/6] RISC-V: Do not use cpumask data structure for hartid bitmap To: Atish Patra Cc: Jessica Clarke , Atish Patra , Linux Kernel Mailing List , Anup Patel , Albert Ou , Damien Le Moal , devicetree , Jisheng Zhang , Krzysztof Kozlowski , linux-riscv , Palmer Dabbelt , Paul Walmsley , Rob Herring Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 28, 2022 at 9:39 AM Geert Uytterhoeven wrote: > On Fri, Jan 28, 2022 at 1:13 AM Atish Patra wrote: > > On Thu, Jan 27, 2022 at 12:48 AM Geert Uytterhoeven wrote: > >> What about shifting hmask and adjusting hbase if a hartid is > >> lower than the current hbase? > > > > That will probably work for current systems but it will fail when we have hartid > 64. > > The below logic as it assumes that the hartids are in order. We can have a situation > > where a two consecutive cpuid belong to hartids that require two invocations of sbi call > > because the number of harts exceeds BITS_PER_LONG. > > If the number of harts exceeds BITS_PER_LONG, you always need multiple > calls, right? > > I think the below (gmail-whitespace-damaged diff) should work: > > --- a/arch/riscv/kernel/sbi.c > +++ b/arch/riscv/kernel/sbi.c > @@ -249,7 +249,7 @@ static void __sbi_set_timer_v02(uint64_t stime_value) > > static int __sbi_send_ipi_v02(const struct cpumask *cpu_mask) > { > - unsigned long hartid, cpuid, hmask = 0, hbase = 0; > + unsigned long hartid, cpuid, hmask = 0, hbase = 0, htop = 0; > struct sbiret ret = {0}; > int result; > > @@ -258,16 +258,27 @@ static int __sbi_send_ipi_v02(const struct > cpumask *cpu_mask) > > for_each_cpu(cpuid, cpu_mask) { > hartid = cpuid_to_hartid_map(cpuid); > - if (hmask && > - (hartid < hbase || hartid >= hbase + BITS_PER_LONG)) { Oops, I actually sent the diff against the simpler solution below, not against the current code, but I guess you get the idea. I can send a proper patch when agreed. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds