Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2156248rdb; Tue, 3 Oct 2023 12:00:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFardyGecRlI9BDmS399qEksi7fNxei35cO+bcTyC9cohjSsPVM6o7856GmLQeo6/C1Z07+ X-Received: by 2002:a05:6358:e49d:b0:143:8af6:48e7 with SMTP id by29-20020a056358e49d00b001438af648e7mr297776rwb.5.1696359601230; Tue, 03 Oct 2023 12:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696359601; cv=none; d=google.com; s=arc-20160816; b=XUDmQWWTF39S4KW5ByZWgOOG48tjsuZUK+t0vYl7UBRvAK7UuxQI7IC8TyiwG4Lv+r SK/rZRnTbDBGynKSR8yrYUAkKPvdmQXM1VC7U8o6ZDf/UsxbNVpG/PnKn/OGXtE8TqnV dDPYEX2mhu+BI2sBcLk9vO3Acwu+h6T3+pg0GoN2Bgs5GVPVIYay4XUIkq8IkS9WVj1z B/sEphEUbs7j7kfNHkpbfkExxW96MskAFtHWnmwbwGsH7x6GnYSTaQmnGGn1ZDqLBdF5 HwnVWWJGjHoxKxnJAttoueLDqAtKqVF3Qy+rMjKmiMoQtG1kSdNPY82lLp6lfCnxkSQn RVcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=g84yvdOkOfK8ImlsVuUfAihWEZ37t2ndqXqg7w/OTXc=; fh=wEKpKvKev9MIWer2LfA+vg/u4+mvwdpLl19UB+UhWgI=; b=Xz2pBwxqO35xRKgrftx7HkUfCd+WiPYV45GJYqFeQXCDRFIC+MLuuJ8O259fa0Rfl8 1rLYEkGAtAmv/W3IsDVWXh2j2rmi7pAkT16rgy8kA0EJm9cg1DGpA1AkII+rHrEDmdRd YDjf8spu2HikN/W5n3l7J1is9/Ag0/tLLiwdTOuEarn90D45TRe+srdBYofITdldAiyR mO8MrtYpM1TtL6CsCyy7LKHFDHEwV2CVF8dYOcj7PAnLOen64zVIvgmbXWEGKFCdsWc6 Ky4KyR12xNnPEP4FMLW7EbTW+OPaD7wizIz3u8hUEB/Z/A3qCU0zE6nrr3cfeZaPt83X EBEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZK+CmrSj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id l62-20020a632541000000b0056f7f18bbfdsi2001988pgl.632.2023.10.03.12.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 12:00:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZK+CmrSj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 164868183261; Tue, 3 Oct 2023 11:59:59 -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 S234299AbjJCS7x (ORCPT + 99 others); Tue, 3 Oct 2023 14:59:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbjJCS7x (ORCPT ); Tue, 3 Oct 2023 14:59:53 -0400 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 CD12D9B for ; Tue, 3 Oct 2023 11:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696359542; 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=g84yvdOkOfK8ImlsVuUfAihWEZ37t2ndqXqg7w/OTXc=; b=ZK+CmrSjGG5uerob61NUChbBYzAdeGgEuZFOpE/29CwjWNPxGEHtHHpb7CiBTZ3Sy7/NQS Z6/s/LB8NCkkX5L+hdBafoJYDala58urqHsbYQjZ9RhMTMwD7wCKJuOO81jkbst3/gyL98 CnTtVaV9FHUI1U06hERTZyw2A+hKu+0= 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-543-MbqZBjz4Ox6XpqSJvysezw-1; Tue, 03 Oct 2023 14:59:00 -0400 X-MC-Unique: MbqZBjz4Ox6XpqSJvysezw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 200AB101A5C5; Tue, 3 Oct 2023 18:59:00 +0000 (UTC) Received: from [10.22.10.176] (unknown [10.22.10.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D1F62156701; Tue, 3 Oct 2023 18:58:59 +0000 (UTC) Message-ID: <320f6e2e-c0ae-3cbd-bc43-d2eabcd70cc4@redhat.com> Date: Tue, 3 Oct 2023 14:58:58 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH v3] sched/core: Use empty mask to reset cpumasks in sched_setaffinity() Content-Language: en-US To: Peter Zijlstra 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 References: <20230804023218.75544-1-longman@redhat.com> <20231003100602.GF27267@noisy.programming.kicks-ass.net> From: Waiman Long In-Reply-To: <20231003100602.GF27267@noisy.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-1.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 11:59:59 -0700 (PDT) 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. Another possible alternative is to use a cpusetsize of 0 to indicate a reset as long as it doesn't cause problem with existing code. Will that be acceptable? Cheers, Longman