From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E18BC56201 for ; Thu, 19 Nov 2020 19:26:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB18224698 for ; Thu, 19 Nov 2020 19:26:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="r7Gvj5r1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728092AbgKSTZ7 (ORCPT ); Thu, 19 Nov 2020 14:25:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:38354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727905AbgKSTZ6 (ORCPT ); Thu, 19 Nov 2020 14:25:58 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7AF6221FE; Thu, 19 Nov 2020 19:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605813958; bh=tpiSO13FbNyZ42kAbeVAMN0z3Q1MzKH9/3qggLww0uQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r7Gvj5r18o4ajlJFxbZptgsKAjyvN81ac7Vl0PWWW7vgY0S4IhHlyeIc5GLyIIw/h pJN+A48yxUDNPeT2M/RVFraejiLdehZ5T+GwLeGCdGiZ/aPb/eGZ19Tm36d84efeEe W3kpJD0CA6Sxju9AI3YUc85X4mQR6ey0TYoH/F3I= Date: Thu, 19 Nov 2020 19:25:51 +0000 From: Will Deacon To: Valentin Schneider Cc: Peter Zijlstra , linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , kernel-team@android.com Subject: Re: [PATCH v3 07/14] sched: Introduce restrict_cpus_allowed_ptr() to limit task CPU affinity Message-ID: <20201119192550.GD4906@willie-the-truck> References: <20201113093720.21106-1-will@kernel.org> <20201113093720.21106-8-will@kernel.org> <20201119131319.GE4331@willie-the-truck> <20201119160944.GP3121392@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 19, 2020 at 04:57:22PM +0000, Valentin Schneider wrote: > > On 19/11/20 16:09, Peter Zijlstra wrote: > > On Thu, Nov 19, 2020 at 01:13:20PM +0000, Will Deacon wrote: > > > >> Sure, but I was talking about what userspace sees, and I don't think it ever > >> sees CPUs that have been hotplugged off, right? That is, sched_getaffinity() > >> masks its result with the active_mask. > > > > # for i in /sys/devices/system/cpu/cpu*/online; do echo -n $i ":"; cat $i; done > > /sys/devices/system/cpu/cpu1/online :0 > > /sys/devices/system/cpu/cpu2/online :1 > > /sys/devices/system/cpu/cpu3/online :1 > > /sys/devices/system/cpu/cpu4/online :1 > > /sys/devices/system/cpu/cpu5/online :1 > > /sys/devices/system/cpu/cpu6/online :1 > > /sys/devices/system/cpu/cpu7/online :1 > > > > # grep Cpus_allowed /proc/self/status > > Cpus_allowed: ff > > Cpus_allowed_list: 0-7 > > > > > > :-) > > Harumph, so there is that... > > $ while true; do continue; done & > $ PID=$! > $ taskset -pc 0-1 $PID > pid 849's current affinity list: 0-5 > pid 849's new affinity list: 0,1 > $ echo 0 > /sys/devices/system/cpu/cpu1/online > [12578.545726] CPU1: shutdown > [12578.548454] psci: CPU1 killed (polled 0 ms) > $ taskset -pc $PID > pid 849's current affinity list: 0 > $ cat /proc/$PID/status | grep Cpus > Cpus_allowed: 03 > Cpus_allowed_list: 0-1 Yeah, I'm not sure this is worth tackling tbh. sched_getaffinity() does the right thing, but poking around in /proc and /sys is always going to defeat the illusion and I don't see what we gain in reporting CPUs on which the task is _never_ going to run anyway. But I'll revise my stance on it being identical to hotplug :) (I would've gotten away with it too, if it wasn't for those pesky hackers). Will From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 130B5C56201 for ; Thu, 19 Nov 2020 19:27:09 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 892C3221FE for ; Thu, 19 Nov 2020 19:27:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="q6dWlvr1"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="r7Gvj5r1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 892C3221FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jl/p3JRzJDdvoGXbzaTjJDM6IUkerYm0BalozMuMohE=; b=q6dWlvr1hw47NP8mqVJLXQafV qneZLUHGkthqkms8kTIxLX93AXrYqweQBTnI4mvIA2CRn/99H/fktXkNVRT6/f0k05sqb1eWh2WNF FEs+FUaEs4oEHrrTjlb+l3cuKli0/vNUVZQdJmUY3L7gUoL/N+13d4w7Rp6ULC5w3VekKiY7P09rp TFyJLekorql0GYuU3nElz3uso4LqviucKtiWJ8dMbsb37c4ZYNEcq1R2HS78Pw+NipR+UcKNiuCTh eb7WRGjWRnpBkZz10+9RBiyD39G/rbx2nkMDql9L2QunuGriLRhKqwIHPHhypYViZc0p9FxSXKPaa Vz5nEQQzg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfpZC-0006z3-3a; Thu, 19 Nov 2020 19:26:02 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfpZ9-0006yD-1m for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2020 19:26:00 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7AF6221FE; Thu, 19 Nov 2020 19:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605813958; bh=tpiSO13FbNyZ42kAbeVAMN0z3Q1MzKH9/3qggLww0uQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r7Gvj5r18o4ajlJFxbZptgsKAjyvN81ac7Vl0PWWW7vgY0S4IhHlyeIc5GLyIIw/h pJN+A48yxUDNPeT2M/RVFraejiLdehZ5T+GwLeGCdGiZ/aPb/eGZ19Tm36d84efeEe W3kpJD0CA6Sxju9AI3YUc85X4mQR6ey0TYoH/F3I= Date: Thu, 19 Nov 2020 19:25:51 +0000 From: Will Deacon To: Valentin Schneider Subject: Re: [PATCH v3 07/14] sched: Introduce restrict_cpus_allowed_ptr() to limit task CPU affinity Message-ID: <20201119192550.GD4906@willie-the-truck> References: <20201113093720.21106-1-will@kernel.org> <20201113093720.21106-8-will@kernel.org> <20201119131319.GE4331@willie-the-truck> <20201119160944.GP3121392@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201119_142559_295802_0B0BBFC7 X-CRM114-Status: GOOD ( 17.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Juri Lelli , kernel-team@android.com, Vincent Guittot , Ingo Molnar , Greg Kroah-Hartman , Peter Zijlstra , Marc Zyngier , Quentin Perret , linux-kernel@vger.kernel.org, Qais Yousef , Johannes Weiner , Li Zefan , Catalin Marinas , Tejun Heo , Suren Baghdasaryan , Morten Rasmussen , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Nov 19, 2020 at 04:57:22PM +0000, Valentin Schneider wrote: > > On 19/11/20 16:09, Peter Zijlstra wrote: > > On Thu, Nov 19, 2020 at 01:13:20PM +0000, Will Deacon wrote: > > > >> Sure, but I was talking about what userspace sees, and I don't think it ever > >> sees CPUs that have been hotplugged off, right? That is, sched_getaffinity() > >> masks its result with the active_mask. > > > > # for i in /sys/devices/system/cpu/cpu*/online; do echo -n $i ":"; cat $i; done > > /sys/devices/system/cpu/cpu1/online :0 > > /sys/devices/system/cpu/cpu2/online :1 > > /sys/devices/system/cpu/cpu3/online :1 > > /sys/devices/system/cpu/cpu4/online :1 > > /sys/devices/system/cpu/cpu5/online :1 > > /sys/devices/system/cpu/cpu6/online :1 > > /sys/devices/system/cpu/cpu7/online :1 > > > > # grep Cpus_allowed /proc/self/status > > Cpus_allowed: ff > > Cpus_allowed_list: 0-7 > > > > > > :-) > > Harumph, so there is that... > > $ while true; do continue; done & > $ PID=$! > $ taskset -pc 0-1 $PID > pid 849's current affinity list: 0-5 > pid 849's new affinity list: 0,1 > $ echo 0 > /sys/devices/system/cpu/cpu1/online > [12578.545726] CPU1: shutdown > [12578.548454] psci: CPU1 killed (polled 0 ms) > $ taskset -pc $PID > pid 849's current affinity list: 0 > $ cat /proc/$PID/status | grep Cpus > Cpus_allowed: 03 > Cpus_allowed_list: 0-1 Yeah, I'm not sure this is worth tackling tbh. sched_getaffinity() does the right thing, but poking around in /proc and /sys is always going to defeat the illusion and I don't see what we gain in reporting CPUs on which the task is _never_ going to run anyway. But I'll revise my stance on it being identical to hotplug :) (I would've gotten away with it too, if it wasn't for those pesky hackers). Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel