Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2234823rdb; Tue, 3 Oct 2023 14:48:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEoorJ2G7x0U1Oab+ZKlB7ENUF4luMArr6wUCmkf94F9frqj7oSGInUypM8LWzB4N6eqey X-Received: by 2002:a05:6870:b294:b0:1b0:43b6:e13b with SMTP id c20-20020a056870b29400b001b043b6e13bmr857490oao.54.1696369728684; Tue, 03 Oct 2023 14:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696369728; cv=none; d=google.com; s=arc-20160816; b=DXAne5PNZvTUUZZZw3KIah0RhsY1TRzgwemNR0EnhvZ9LG8Tom4xJI6J+L/wbL/2up iamzfIfbjO9iZgBSxaB5U3XG57RhA4iSiJ5VHuqsb+tgeQna06vOYKxqjRLk3Kmy8Bjb P7kV1WGpjNI9hAJOUHQoEYmWbN4xCZJm2mREhUB0lTdAUv4wRFBplQAorZ+Z9c01u5tU dD2/Ymj8HLURLCGESUL0XjXf7LNRfLol+pF15Tm7gf7kkQVm4duUCRwP/hVZdYUVEexQ tH+vUvIPJmmfhhjDJG1ggrArHr0Tn2qs1hCMlaZXFHocnUvya2hFvYOBrzqpW2IWUfiM d5cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GhmbQyYJOogKc2OlN+UN4K7WylEhZzt31aBp6zvEslc=; fh=V0EURbwsq7Qih4wMvIjmsEfh6adx2pujvE2D4CqkJSY=; b=cKRGb/txRHOGq3wCodX2rKAgY7I053lZMuuRM9YsQxzvlg1PgPOO/nIqmnxmAWQQ/a Fy/ryIOVlXyEeJoTLnFi3L5efa0gO4iFbOEijnVc9tfEwnYGwsXnI3yg/1XN1Ph6i0w3 OyYCuLAt8Fik5gPfFZWGc/s0qi85CPhxtwiNDR/HdiFT41PP5CZJG0eFAPNxA+RzWoi5 45QRACpA26pboaSTXeYUqagjunWoDxH0dSEq0jV6hRCPpGTtvrYh4u6+ebr8Yyx20p9/ cyClDkOESzL435KZKvxbH4R9JGnKmJRTEgPrjHWWf4f9pVkt2DWFCWUSr1tNRn5uue8e lvQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Y3CbxWdl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id p19-20020a63fe13000000b00584d16c6439si2311349pgh.622.2023.10.03.14.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 14:48:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Y3CbxWdl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E17BD8174A51; Tue, 3 Oct 2023 14:48:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241267AbjJCVsi (ORCPT + 99 others); Tue, 3 Oct 2023 17:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232049AbjJCVsh (ORCPT ); Tue, 3 Oct 2023 17:48:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCA0AA1 for ; Tue, 3 Oct 2023 14:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GhmbQyYJOogKc2OlN+UN4K7WylEhZzt31aBp6zvEslc=; b=Y3CbxWdlVveozxN5h4v078B8Z5 +Wo118ggvtjD/CzjdG682q9k6CA6vFHnSnudP3kbua15ncDUJn2gPEXD1X1aTYa638NQYszz776G+ aWuwKrJVvbMm+aRJqDliGfA3xop9nwS1hQq5j2is1JXqZb4qRUyNPlAfGqNW1V90GWs0+IQGNMw0O dp+HJ7+xamXJ563CdQQXCj/Nm4MJR+ojEREPqSqPjKYNadn1Z+RbDiuOtqPRtxDDLig7MC27CtRQ/ EwxVvqFba9Kaig78ui7arwKYUFeFMxi8WZPMs6PxuRXxLgT47u1WXwZowQoByNMwzGkggjsECPmVW MQbN7SYg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qnnFe-00HJM1-GL; Tue, 03 Oct 2023 21:48:22 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 2E14830036C; Tue, 3 Oct 2023 23:48:22 +0200 (CEST) Date: Tue, 3 Oct 2023 23:48:22 +0200 From: Peter Zijlstra To: Waiman Long Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org, Phil Auld , Brent Rowsell , Peter Hunt Subject: Re: [PATCH v3] sched/core: Use empty mask to reset cpumasks in sched_setaffinity() Message-ID: <20231003214822.GI1539@noisy.programming.kicks-ass.net> References: <20230804023218.75544-1-longman@redhat.com> <20231003100602.GF27267@noisy.programming.kicks-ass.net> <320f6e2e-c0ae-3cbd-bc43-d2eabcd70cc4@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <320f6e2e-c0ae-3cbd-bc43-d2eabcd70cc4@redhat.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 14:48:46 -0700 (PDT) On Tue, Oct 03, 2023 at 02:58:58PM -0400, Waiman Long wrote: > > On 10/3/23 06:06, Peter Zijlstra wrote: > > On Thu, Aug 03, 2023 at 10:32:18PM -0400, Waiman Long wrote: > > > Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested > > > cpumask"), user provided CPU affinity via sched_setaffinity(2) is > > > perserved even if the task is being moved to a different cpuset. However, > > > that affinity is also being inherited by any subsequently created child > > > processes which may not want or be aware of that affinity. > > > > > > One way to solve this problem is to provide a way to back off from > > > that user provided CPU affinity. This patch implements such a scheme > > > by using an empty cpumask to signal a reset of the cpumasks to the > > > default as allowed by the current cpuset. > > So I still don't like this much, the normal state is all bits set: > > > > $ grep allowed /proc/self/status > > Cpus_allowed: ff,ffffffff > > > > The all clear bitmask just feels weird for this. > > The main reason for using an empty bitmask is the presence of the CPU_ZERO() > macro that can produce this empty cpumask. It is certainly possible to use > an all set bitmask for reset purpose. The only problem is it is more > complicated to generate such a bitmask as there is no existing CPU* macros > that can be used. Blergh, FreeBSD has CPU_FILL(), but it appears we don't have this. Still, nothing a memset can't fix. CPU_ZERO() ends up in __builtin_memset() too. I'm sure our glibc boys can add CPU_FILL() eventually. Anyway, I see you sent a v4, I'll go look at that in the am, sleep now.