Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp398333ybl; Thu, 23 Jan 2020 00:20:51 -0800 (PST) X-Google-Smtp-Source: APXvYqzr0hwBBR1rx0qXYLcwWEfbuNb0INaKLDDSUbkCfNPGQacMvfVD5IWTxNm4b4xLW9/MH9Of X-Received: by 2002:a9d:518b:: with SMTP id y11mr9958488otg.349.1579767651581; Thu, 23 Jan 2020 00:20:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579767651; cv=none; d=google.com; s=arc-20160816; b=JBTJZ4h8UBZDtDZgu94RRw4nRNpkhjAA0omSv9MoRKcUsz5w5Mo3ukzN7ANOsZx+Rs Tmoge/hHvyLV0YNMd09xKWya5zI/cNzC8zKpq1epUyM26Dn0cGREPtPsnaSp4gElog2t oNuJgfuLekTSolsIoIWsUpgPydokOGqSKqhyZ4Nh77Ym0fakpleOgOUeZyuQvAHUEVGm AUpI3poAzhabt6ErHYkS3bXat4l2nw8UPL1S+zJSi5M8hvjCGmP6EDYkWChG0lXGLXTF monHO6HJhjTTCUD0E3+8D0RgTZnyiUTsJM5dcXsLOhCx15YXBlGto6OEQ1SVGA0ZylNQ QrPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature; bh=r8G9CiUcTrvaUADmAjAIB3KCKMVrK5hIYghUAfanm1s=; b=DAUpaPWONmc+0Mkq1zaJ8xAnpX6t5unOyWAqVMAnGnFoag43MzqnjBYecsfWZ6VLPk 8zKZ6XXLaKfMg0Qo4tFnxq+gKy1gdbkykPoOrnpzv/FlQeLbtLU0rNIFKEZIZN3ik7MN LKW20CtowDIaepHc+S0mCKnM5aoMQZ4EUnY6Fj5S46P+x53Swz8cmd74NczKF6oOprt2 2sJcJVkanp9yv4TQ+2RZLTpH2b7eMuJeAqawobIcmqBkd61ed2kgCnfReHkUcUL+aalE 6+PJwsX5pWLsdLKeKp22G3tQeZH4h9dEYnxUQAwAh7dkWIqQykst0ebqzN3DV34wY02+ uQMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FoZFuOpI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id r1si776712otq.298.2020.01.23.00.20.39; Thu, 23 Jan 2020 00:20:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FoZFuOpI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726780AbgAWITf (ORCPT + 99 others); Thu, 23 Jan 2020 03:19:35 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:59704 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726083AbgAWITf (ORCPT ); Thu, 23 Jan 2020 03:19:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579767574; 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: in-reply-to:in-reply-to:references:references; bh=r8G9CiUcTrvaUADmAjAIB3KCKMVrK5hIYghUAfanm1s=; b=FoZFuOpIBG+mw4dSFEXvDtg/itXuFJfoMRiAySH74ydGir4rNFSGmGyiqAc07VWfY2Vf88 nTOBsZtWqWBvbx3chaDz+QzZo9UHXzNTBs4lPkEtJa5/E15aIv2wwlJpAT5LXMjh+SR6O8 lWA0NC3Z/HCtSklwh2gCm/q+yGeVTS8= 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-161-GDK3HAbMObCnYJNP01EYcQ-1; Thu, 23 Jan 2020 03:19:30 -0500 X-MC-Unique: GDK3HAbMObCnYJNP01EYcQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0034A1800D48; Thu, 23 Jan 2020 08:19:27 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-116-150.ams2.redhat.com [10.36.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B137581C0A; Thu, 23 Jan 2020 08:19:20 +0000 (UTC) From: Florian Weimer To: "H. Peter Anvin" Cc: Mathieu Desnoyers , Chris Lameter , Jann Horn , Peter Zijlstra , Thomas Gleixner , linux-kernel , Joel Fernandes , Ingo Molnar , Catalin Marinas , Dave Watson , Will Deacon , shuah , Andi Kleen , linux-kselftest , Russell King , Michael Kerrisk , Paul , Paul Turner , Boqun Feng , Josh Triplett , rostedt , Ben Maurer , linux-api , Andy Lutomirski Subject: Re: [RFC PATCH v1] pin_on_cpu: Introduce thread CPU pinning system call References: <20200121160312.26545-1-mathieu.desnoyers@efficios.com> <430172781.596271.1579636021412.JavaMail.zimbra@efficios.com> <2049164886.596497.1579641536619.JavaMail.zimbra@efficios.com> <1648013936.596672.1579655468604.JavaMail.zimbra@efficios.com> Date: Thu, 23 Jan 2020 09:19:18 +0100 In-Reply-To: (H. Peter Anvin's message of "Wed, 22 Jan 2020 23:53:54 -0800") Message-ID: <87a76efuux.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 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * H. Peter Anvin: > On 2020-01-21 17:11, Mathieu Desnoyers wrote: >> ----- On Jan 21, 2020, at 4:44 PM, Chris Lameter cl@linux.com wrote: >> >>> These scenarios are all pretty complex and will be difficult to understand >>> for the user of these APIs. >>> >>> I think the easiest solution (and most comprehensible) is for the user >>> space process that does per cpu operations to get some sort of signal. If >>> its not able to handle that then terminate it. The code makes a basic >>> assumption after all that the process is running on a specific cpu. If >>> this is no longer the case then its better to abort if the process cannot >>> handle moving to a different processor. >> >> The point of pin_on_cpu() is to allow threads to access per-cpu data >> structures belonging to a given CPU even if they cannot run on that >> CPU (because it is offline). >> >> I am not sure what scenario your signal delivery proposal aims to cover. >> >> Just to try to put this into the context of a specific scenario to see >> if I understand your point, is the following what you have in mind ? >> >> 1. Thread A issues pin_on_cpu(5), >> 2. Thread B issues sched_setaffinity removing cpu 5 from thread A's >> affinity mask, >> 3. Noticing that it would generate an invalid combination, rather than >> failing sched_setaffinity, it would send a SIGSEGV (or other) signal >> to thread A. >> >> Or so you have something entirely different in mind ? >> > > I would agree that this seems like the only sane option, or you will > be in a world of hurt because of conflicting semantics. It is not just > offlining, but what happens if a policy manager calls > sched_setaffinity() on another thread -- and now the universe breaks > because a library is updated to use this new system call which > collides with the expectations of the policy manager. Yes, this new interface seems fundamentally incompatible with how affinity masks are changed today. Would it be possible to make pin_on_cpu_set to use fallback synchronization via a futex if the CPU cannot be acquired by running on it? The rseq section would need to check the futex as well, but would not have to acquire it. Thanks, Florian