Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp185376ybt; Mon, 6 Jul 2020 07:02:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1EKPXoR1b6blOmQI4tR5+cG5DqUe65hcOnvWH41TKPxXyjn5cwW/ehOCUlftLMjh+P7J4 X-Received: by 2002:aa7:ce91:: with SMTP id y17mr34612169edv.105.1594044167999; Mon, 06 Jul 2020 07:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594044167; cv=none; d=google.com; s=arc-20160816; b=T8FTYpSpLsiDl3ANZttSUBDllzzcWGshT9mSvGyJkut21fHO4eMbnkRmRCZcfT2NxM br50Pb+kbNggRiHhsg3J6uOQrLhGK4dhN7Olcg0IF/gSjojSSZPEdga1HNgPAp77oGyL NVqzqL7tYgcYWBbvabHG+U0MdDBTN0RtGLVU31VIWOCGYNkTd+LBA724hjCb8d8ep2tQ oMbel3uvGwAQxIz90pJa8BXls/dWu5ELb35CT40QSmy6JaOfiAagmpRBbPS74EYcd+/0 Ugn7TAqncWSVSfohGcOHR+iNV4e7ogQwVco4XO4PPy2japMxiv0do8l3hKI7DREotX1I wY4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=DK4/PcR5dFxByvykusuy2iYWwJ1NONwxquwieynQjzM=; b=P21tIe/rfhGvjW5Z8ljWkNlKYP6ZD+FWyNpZ/6sB/1lK35MoCx0qem+i463vuTfryh +YI+qU+D3DEUVLiiTotyIE/UtTlVUm/JgzoeHbW3VGK3fM7sdwo+m25r8VN/AqNuBdZB s07ys/bapkCwZON+apQUA4BdxIjad82SjVFLohjW+b07TYAx7TapHX4SYDeFUYuTpDCp Zfhi72hi2qUkZfsUwd7JoV5vW7wyTBeca5RIbJP07jjkOZjScYLbcIuOZIA6ebiUq6ub ceOpf69BcGsG9S6x+sXJ5b5alos434buILnNtooTw8tUXjo7wksZjCDKp8VAqehAFjAR zuQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gvdVXroX; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y19si13311842ejm.324.2020.07.06.07.02.25; Mon, 06 Jul 2020 07:02:47 -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=@redhat.com header.s=mimecast20190719 header.b=gvdVXroX; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729261AbgGFN7t (ORCPT + 99 others); Mon, 6 Jul 2020 09:59:49 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:55112 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728940AbgGFN7t (ORCPT ); Mon, 6 Jul 2020 09:59:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594043988; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DK4/PcR5dFxByvykusuy2iYWwJ1NONwxquwieynQjzM=; b=gvdVXroXw2gbtQsn2IFxiZySah/vltpBloWj/eUT6+0cawFL2ExMk2g8h9j7Zk0D0FRfQB 9MrauSENU0XUGZ2bgY3EoDvJftK9O+SV+QhlyHDcty8HF59yU3msGNHD2Z7/diaiuBNbk2 EpawBQzVMSBcLxwJ7T7aM8mLE77UXGE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-JNc9btf_MXefKsQBKiCktw-1; Mon, 06 Jul 2020 09:59:44 -0400 X-MC-Unique: JNc9btf_MXefKsQBKiCktw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA6F2107ACF3; Mon, 6 Jul 2020 13:59:42 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-118.ams2.redhat.com [10.36.112.118]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D35471665; Mon, 6 Jul 2020 13:59:36 +0000 (UTC) From: Florian Weimer To: Mathieu Desnoyers Cc: Carlos O'Donell , Joseph Myers , Szabolcs Nagy , libc-alpha@sourceware.org, Thomas Gleixner , Ben Maurer , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Will Deacon , Paul Turner , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Subject: Re: [PATCH 2/3] Linux: Use rseq in sched_getcpu if available (v9) References: <20200629190036.26982-1-mathieu.desnoyers@efficios.com> <20200629190036.26982-3-mathieu.desnoyers@efficios.com> Date: Mon, 06 Jul 2020 15:59:35 +0200 In-Reply-To: <20200629190036.26982-3-mathieu.desnoyers@efficios.com> (Mathieu Desnoyers's message of "Mon, 29 Jun 2020 15:00:35 -0400") Message-ID: <877dvg4ud4.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mathieu Desnoyers: > When available, use the cpu_id field from __rseq_abi on Linux to > implement sched_getcpu(). Fall-back on the vgetcpu vDSO if > unavailable. I've pushed this to glibc master, but unfortunately it looks like this exposes a kernel bug related to affinity mask changes. After building and testing glibc, this for x in {1..2000} ; do posix/tst-affinity-static & done produces some =E2=80=9Cerror:=E2=80=9D lines for me: 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 =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. 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). 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). 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. Thanks, Florian