Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp222053ybt; Mon, 6 Jul 2020 07:50:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkwFTKiVvGfqtGdJyzsEyR/zv3W67AKPVKkLpOO+wV6pLFOOvi2DrLhX4PH8kMRgk+Izv1 X-Received: by 2002:aa7:c749:: with SMTP id c9mr54863605eds.107.1594047037608; Mon, 06 Jul 2020 07:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594047037; cv=none; d=google.com; s=arc-20160816; b=oHn6DD/FrP0GuPRUf9ACl4v0F8HSaDo2Xi3H2HIHrgoPxWnIo3gAgETxaR9IuTUxHq +/VKVeCaukOeGQrmXn34yhk6u7dXeKRW6IN9U4XLJ8dDVNQXarBWeemkrGdcO1exvm/x Rib+0CY1eHTFRaeUJqHSDtonqpeiJoW6GUPttP4BS4FWpZW3UYsEy5WK45DSsIfu/cVY qKYfiiR1yxWe9b2NLo/P06ko4NQcIuI8v2tuKYaHT3Ss+qSC34YP7dz2xrwG7t6vH8bW mCrSpxwAnla/dDG6agTriKumZvTmWRG7BDQGns+VT09gviasFriLTWh5+XQMi+nHcnpi Gm5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=8gAqoabmX0YflNXKWP2tfZI2xQ9rxWmk8Vog6l1Uejc=; b=Tri6+Cy3T9sR/+5kLgWj/dc/MTpIh7/AKzXFYZv1EJgIQWt3P2SdBQtGBpIJQotEFc JqSBQOHahWwP18WN3u1Ck5M6sW0kNjVOKteEFnwShXGC7CrMhVlTaM9qkQNsqhjbCgg0 NAFPxucb/bOsUAhXmTvr7ydIhqHzfBrYsMFKscTbaInZf94+cVilhgHsOOsCsQ7J2ap/ +apZZ7uXAQ+JfKfzDhvqzBwJoma3vP2XTtff9133GHqdDN0zfTpl48HXAvvP0vvD20H4 yKW5a/M4J4AcIQ98V3S8QRbI6mD6q0Wll9HSugpNQjRmRulo1rAG9eeofiPoPbb+aGUi S9/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b="rxQ/oIwF"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h25si14417896edv.231.2020.07.06.07.50.15; Mon, 06 Jul 2020 07:50:37 -0700 (PDT) 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; dkim=pass header.i=@efficios.com header.s=default header.b="rxQ/oIwF"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729449AbgGFOto (ORCPT + 99 others); Mon, 6 Jul 2020 10:49:44 -0400 Received: from mail.efficios.com ([167.114.26.124]:57410 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729432AbgGFOtl (ORCPT ); Mon, 6 Jul 2020 10:49:41 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 63F692D8429; Mon, 6 Jul 2020 10:49:39 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id nGbNS3E2RCRr; Mon, 6 Jul 2020 10:49:39 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 198852D8339; Mon, 6 Jul 2020 10:49:39 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 198852D8339 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1594046979; bh=8gAqoabmX0YflNXKWP2tfZI2xQ9rxWmk8Vog6l1Uejc=; h=Date:From:To:Message-ID:MIME-Version; b=rxQ/oIwF2PU+6lDE1w7+Geq7Z0Y1xfBDUbTcERHIo8TBUptlVm2rd7oeSbrLdHCZ+ ycEdmDsAdFEno27tUxe+lyUxu0o935KL5RsDp4TvSOQ05IlqyuoVBrMzs2NKC7l2Q/ SFlFR30T0hgUDcvu8OqLfgiql/gHSPtifh5np5FBsqZ6jJSsQGBEPj5D46SyW67wZR DevmD+6sNIni81jClilhGrBOw1/eYObNrxmpP9rHFBPzlgmiHudybM7kgpVVJe6UiZ ac1X8F0DLGYAx3kLn52tuS0WeG7/Fc1/kdVE8aeIwSNsTaDW28Y28ILjwgvTB8U8tE Wqdpb23RS1fkg== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FXEvtcbaTxen; Mon, 6 Jul 2020 10:49:39 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 094812D8338; Mon, 6 Jul 2020 10:49:39 -0400 (EDT) Date: Mon, 6 Jul 2020 10:49:38 -0400 (EDT) From: Mathieu Desnoyers To: Florian Weimer Cc: carlos , Joseph Myers , Szabolcs Nagy , libc-alpha , Thomas Gleixner , Ben Maurer , Peter Zijlstra , Paul , Boqun Feng , Will Deacon , Paul Turner , linux-kernel , linux-api Message-ID: <942999672.22574.1594046978937.JavaMail.zimbra@efficios.com> In-Reply-To: <877dvg4ud4.fsf@oldenburg2.str.redhat.com> References: <20200629190036.26982-1-mathieu.desnoyers@efficios.com> <20200629190036.26982-3-mathieu.desnoyers@efficios.com> <877dvg4ud4.fsf@oldenburg2.str.redhat.com> Subject: Re: [PATCH 2/3] Linux: Use rseq in sched_getcpu if available (v9) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3945 (ZimbraWebClient - FF78 (Linux)/8.8.15_GA_3928) Thread-Topic: Linux: Use rseq in sched_getcpu if available (v9) Thread-Index: s+lDRWKNxhAkUDtcGJ1GCFO2e2bJlg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jul 6, 2020, at 9:59 AM, Florian Weimer fweimer@redhat.com wrote: > * Mathieu Desnoyers: >=20 >> When available, use the cpu_id field from __rseq_abi on Linux to >> implement sched_getcpu(). Fall-back on the vgetcpu vDSO if >> unavailable. >=20 > I've pushed this to glibc master, but unfortunately it looks like this > exposes a kernel bug related to affinity mask changes. >=20 > After building and testing glibc, this >=20 > for x in {1..2000} ; do posix/tst-affinity-static & done >=20 > produces some =E2=80=9Cerror:=E2=80=9D lines for me: >=20 > error: Unexpected CPU 2, expected 0 > error: Unexpected CPU 2, expected 0 > error: Unexpected CPU 2, expected 0 > error: Unexpected CPU 2, expected 0 > error: Unexpected CPU 138, expected 0 > error: Unexpected CPU 138, expected 0 > error: Unexpected CPU 138, expected 0 > error: Unexpected CPU 138, expected 0 >=20 > =E2=80=9Cexpected 0=E2=80=9D is a result of how the test has been written= , it bails out > on the first failure, which happens with CPU ID 0. >=20 > Smaller systems can use a smaller count than 2000 to reproduce this. It > also happens sporadically when running the glibc test suite itself > (which is why it took further testing to reveal this issue). >=20 > I can reproduce this with the Debian 4.19.118-2+deb10u1 kernel, the > Fedora 5.6.19-300.fc32 kernel, and the Red Hat Enterprise Linux kernel > 4.18.0-193.el8 (all x86_64). >=20 > As to the cause, I'd guess that the exit path in the sched_setaffinity > system call fails to update the rseq area, so that userspace can observe > the outdated CPU ID there. Hi Florian, We have a similar test in Linux, see tools/testing/selftests/rseq/basic_tes= t.c. That test does not trigger this issue, even when executed repeatedly. I'll investigate further what is happening within the glibc test. Thanks, Mathieu --=20 Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com