Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9263150rwl; Wed, 11 Jan 2023 03:40:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXtGcLzlTtX6jJ2kOM6SFN6sOFyU9rSp/9u1kbobB5TCPPkmdBtadBLhIKgyT94x79VsE7Dm X-Received: by 2002:a17:906:9bf4:b0:84d:141b:7e4b with SMTP id de52-20020a1709069bf400b0084d141b7e4bmr17294817ejc.76.1673437228926; Wed, 11 Jan 2023 03:40:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673437228; cv=none; d=google.com; s=arc-20160816; b=pttBWAze3cypw8cxPHrqVrfYfdHbvdzfi/XzJS4A3mSOR9gB40KApf/BYylgLpsOMm Nv1OF4gfNYy6BgaIDwn5+L8p+C7Kr4p3iKiVhisDD1n5gyXwJvYS9a5XaIwP3k3Jf6Ig HxvOFLKoGW0GOPU7refXIk9j7fzkJ7Ejzf785QQHkemuczwmvT044ttPQWQfDXFf3s8X OBbc1gUMDKhdjL43eyr0GredOUD/rxjS1A8gcsvnJKDWzBaFktg4m9d5y6HJsNIAbaQ7 VDMD9n4Pqowk3YwkihjMAcvnoYqDwTEj7eCzbaZl8TYwZLY9R3z6drjN+qYc1zQNoPiO Q4Ig== 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:message-id:date:subject :cc:to:from:dkim-signature; bh=P26DOOQFzqNeAWOv5m+Y0df/LIVzCBSEjc0esr8v7WM=; b=tNZ74NBKJ1mJrrK8JAIsgTl77u5rRns3C3QkKX/vt72FiCNmn2rIC+sBqZTO+kOfER /mQ23e4e8hqlfS8SmDyIPkC//tWiN+wnt1IJC9uf/9SPTEeua/F5IEgjcx2R+43lHumY vjYw53Qx2DxZoOjt3U9nfRBcF+o4KAYYPorxkDzbh5KF60InBbKKbbOmPaq7powEACoz 0AHU1Pce3r0TOZyE6rMFQQEl93WqEEUNsiut8pwTeIL7t/lG20g4S266fjAmyVr85Qn8 ctHsgGhAsltG4QTFXDU4X3saOlzEvEHjF7w4PvkfWkWNsCoeZE3o7cmglb+lZXsFEHSS rPSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C7fh3cBf; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wv4-20020a170907080400b007c18e1ecaf5si16306883ejb.654.2023.01.11.03.40.15; Wed, 11 Jan 2023 03:40:28 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=C7fh3cBf; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbjAKL2T (ORCPT + 53 others); Wed, 11 Jan 2023 06:28:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231499AbjAKL1U (ORCPT ); Wed, 11 Jan 2023 06:27:20 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EDEE140B3 for ; Wed, 11 Jan 2023 03:26:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673436374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=P26DOOQFzqNeAWOv5m+Y0df/LIVzCBSEjc0esr8v7WM=; b=C7fh3cBfPZmFQBc43gT/qaqrBzG6nrskD9lUqSj/hMX3K9j/6QkrPLSQ+E9LFu1Y4FtVP1 jwoak6Wluyr52y/O+gzgdwlR/4++jovnhlr1WxQyfzdlZsUNSu3d0AynZeg0Sy5kr0qBBx fS5VSDseQu/PWfM5DgHmAI3r2rNzdYo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-495-9j7wO3_EPBmW4mvMbHkoBg-1; Wed, 11 Jan 2023 06:26:11 -0500 X-MC-Unique: 9j7wO3_EPBmW4mvMbHkoBg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07D08858F09; Wed, 11 Jan 2023 11:26:11 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A058492C14; Wed, 11 Jan 2023 11:26:10 +0000 (UTC) From: Florian Weimer To: Mathieu Desnoyers , linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , libc-alpha@sourceware.org Subject: rseq CPU ID not correct on 6.0 kernels for pinned threads Date: Wed, 11 Jan 2023 12:26:08 +0100 Message-ID: <87lem9cnxr.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 The glibc test suite contains a test that verifies that sched_getcpu returns the expected CPU number for a thread that is pinned (via sched_setaffinity) to a specific CPU. There are other threads running which attempt to de-schedule the pinned thread from its CPU. I believe the test is correctly doing what it is expected to do; it is invalid only if one believes that it is okay for the kernel to disregard the affinity mask for scheduling decisions. These days, we use the cpu_id rseq field as the return value of sched_getcpu if the kernel has rseq support (which it has in these cases). This test has started failing sporadically for us, some time around kernel 6.0. I see failure occasionally on a Fedora builder, it runs: Linux buildvm-x86-26.iad2.fedoraproject.org 6.0.15-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Dec 21 18:33:23 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux I think I've seen it on the x86-64 builder only, but that might just be an accident. The failing tests log this output: =====FAIL: nptl/tst-thread-affinity-pthread.out===== info: Detected CPU set size (in bits): 64 info: Maximum test CPU: 5 error: Pinned thread 1 ran on impossible cpu 0 error: Pinned thread 0 ran on impossible cpu 0 info: Main thread ran on 4 CPU(s) of 6 available CPU(s) info: Other threads ran on 6 CPU(s) =====FAIL: nptl/tst-thread-affinity-pthread2.out===== info: Detected CPU set size (in bits): 64 info: Maximum test CPU: 5 error: Pinned thread 1 ran on impossible cpu 1 error: Pinned thread 2 ran on impossible cpu 0 error: Pinned thread 3 ran on impossible cpu 3 info: Main thread ran on 5 CPU(s) of 6 available CPU(s) info: Other threads ran on 6 CPU(s) But I also encountered one local failure, but it is rare. Maybe it's load-related. There shouldn't be any CPU unplug or anything like that involved here. I am not entirely sure if something is changing CPU affinities from outside the process (which would be quite wrong, but not a kernel bug). But in the past, our glibc test has detected real rseq cpu_id brokenness, so I'm leaning towards that as the cause this time, too. Thanks, Florian