Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5017288rwb; Mon, 8 Aug 2022 10:37:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ZtJkITVGDMk94wxvEi/0ukdnjAp639inUbIzClxFBqm9trmzO4zrlCoPr7Q7fUTgJUJOV X-Received: by 2002:a17:902:988a:b0:16e:d52a:cce4 with SMTP id s10-20020a170902988a00b0016ed52acce4mr20013504plp.127.1659980260554; Mon, 08 Aug 2022 10:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659980260; cv=none; d=google.com; s=arc-20160816; b=eEaiOMs2/hFoEhzfba+S0BMPfs3D83Id7fRisWlBrF2ufu4aYJnb77d1DhoW7H7Ddr Ld2oDS1FCZXT7DsqFeDCPLRce4o8PpSrFhZ1RXDcX7iiA1+cx7tDwwOz+Jcrox8Wh9Co 9ZqKY4xDAbXUBhwIHYQw6Gr4FrI9O4ewt6otzyrMQ0il4/K0DGJ+aA46v2gYvbmrZM9m TfON6v9Drx49GC8ySiPtgATrinJ7v60pfcCMPWrIax6pU3R7QpAPdp4Hf2O/SGxc613A DV65xI7597nOs8hWKN/iqMS6EHFZA36uUDxFxCG+jEN30Hufr/gay4ZJJDYKd46nTgnb o4pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:to:from :subject:message-id:dkim-signature; bh=ai4PGhiAGMc1RPAIPLKcFdsH6r8r6WIRdg+EJXmtchg=; b=UYRlOOUjmfuBKtO6Zmviy07GBrP3OBUerpu/6kPyp30FkvTRnwStAbLMqdku66sjFz QAajMOYOjPaDEDNGoHNeY23A1/MRhW5q0xz1SA0WunB3fHav/0bbGsHcXBKQCH5fekid JwZpOCbj21ShirsxjEQajWiOJAlE/lE9Y9tSr7EjNhaLHW0lFXYmQ5EKSVGNZg1dB3wD fYkV4XjcNhvVQV8RB52znzk1H3Cp+lnEo8tTTHUdDXpTno+2ty+x3gKN/V3ChfPe1m+T 00pZUI2wr4ErDlEPo0aB3cJPbyQFHAmALmXFle5hw8BDnF5Tmy/7/3brlrdm/SrYJtZK g5hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svanheule.net header.s=mail1707 header.b=9VZW1zym; 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 d8-20020a631d08000000b0041bdae7558esi11348164pgd.653.2022.08.08.10.37.25; Mon, 08 Aug 2022 10:37:40 -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=9VZW1zym; 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 S243316AbiHHRfC (ORCPT + 99 others); Mon, 8 Aug 2022 13:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235852AbiHHRfB (ORCPT ); Mon, 8 Aug 2022 13:35:01 -0400 Received: from polaris.svanheule.net (polaris.svanheule.net [84.16.241.116]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8BAE1704C for ; Mon, 8 Aug 2022 10:34:56 -0700 (PDT) Received: from [IPv6:2a02:a03f:eaf9:8401:aa9f:5d01:1b2a:e3cd] (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 A9F2E308464; Mon, 8 Aug 2022 19:34:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1659980094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ai4PGhiAGMc1RPAIPLKcFdsH6r8r6WIRdg+EJXmtchg=; b=9VZW1zymZAiaVP8EkA0pmw5nqIfOXHuvGe40pAQQ7m1Zg6FEptK8WTVof8drXlhzbVy8zr IclwPwLTFdQaiJbHcpPmDPos0Fv/+JGZRgAcM2CIAUivQaJKagTrD5Zt0j3k8GUDCw3878 1Q0i6AVzfiMKo0NSU6R5wvavdhYJdjXAFXgpVcREWOY6PR+XWGbEaOHyL4CoGyNsSoQ2/L I0u5ERt6zzB0OU8d9bXMu8UYwhVLoTv3+wMI5rBXVE3+37Tdao5p7XG9rg4brzwCiaBT3W lYhnK37NRROPsdV3DJywBIgwLbD453nnd8jXIppaI2BU08LZj7xol/dHsKln/g== Message-ID: Subject: Re: [RFC] issue with cpumask for UniProcessor From: Sander Vanheule To: Saurabh Sengar , ssengar@microsoft.com, mikelley@microsoft.com, linux-kernel@vger.kernel.org Date: Mon, 08 Aug 2022 19:34:53 +0200 In-Reply-To: <1659975821-30762-1-git-send-email-ssengar@linux.microsoft.com> References: <1659975821-30762-1-git-send-email-ssengar@linux.microsoft.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.3 (3.44.3-1.fc36) MIME-Version: 1.0 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 Hi Saurabh, On Mon, 2022-08-08 at 09:23 -0700, Saurabh Sengar wrote: >=20 > Hi, >=20 > I am working on a UniProcessor system with latest linux-next kernel > (20220803). > I observed two files "shared_cpu_map=E2=80=9D and =E2=80=9Cshared_cpu_lis= t=E2=80=9D are missing > for L3 cache (/sys/devices/system/cpu/cpu0/cache/index3). This causes lsc= pu > version 2.34 to segfault. On further digging I figured below is the commi= t > which introduced this problem. >=20 > https://lore.kernel.org/lkml/e78c55ecb98172356248a7a89da501479ead6ae0.165= 9077534.git.sander@svanheule.net/ >=20 This is the v5 of the patch, which sadly isn't the version that got merged.= The commit that's triggering your issue is b81dce77cedc ("cpumask: Fix invalid uniprocessor mask assumption"), which is patch v4. https://lore.kernel.org/lkml/86bf3f005abba2d92120ddd0809235cab4f759a6.16567= 77646.git.sander@svanheule.net/ >=20 > I am not 100% certain what the proper fix for it is, but below changes fi= x > this issue. I understand above patch is already confirmed for linux kerne= l > 6.0, please suggest if we need fixing this in 6.0. >=20 > Regards, > Saurabh >=20 >=20 >=20 > diff --git a/lib/cpumask.c b/lib/cpumask.c > index b9728513a4d4..81fc2e35b5b1 100644 > --- a/lib/cpumask.c > +++ b/lib/cpumask.c > @@ -16,10 +16,14 @@ > =C2=A0 */ > =C2=A0unsigned int cpumask_next(int n, const struct cpumask *srcp) > =C2=A0{ > +#if NR_CPUS =3D=3D 1 > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return n+1; > +#else This is ignoring the provided cpumask again, which was exactly what my patc= h fixed. If the mask is empty, then cpumask_next(-1, mask) should return (at least) 1, not 0. I think the problem could be caused by cpumask_next() getting an empty mask= . Then the real issue is would be that a certain mask is empty when it should= n't be, which was compensated by the old code's built-in assumption that a cpum= ask couldn't be empty. My MIPS testing system doesn't have these L3 maps, and "shared_cpu_map" and "shared_cpu_list" are present for index0 and index1. I would propose that y= ou look for the point where the files should be created, and check how cpumask_next() is involved, to find the actual cause of this problem. Best, Sander > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* -1 is a legal arg here. */ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (n !=3D -1) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 cpumask_check(n); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return find_next_bit(cpumask_b= its(srcp), nr_cpumask_bits, n + 1); > +#endif > =C2=A0} > =C2=A0EXPORT_SYMBOL(cpumask_next);