Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp26328015rwd; Mon, 3 Jul 2023 08:15:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlEVymapuyopT8lgyUtUjBjG0Aqaq0BgaR3+kOnr5X55DT+1wZAHRsyeA5h/GlbaCsluiH3o X-Received: by 2002:a17:902:e995:b0:1b8:6cf8:42da with SMTP id f21-20020a170902e99500b001b86cf842damr10680539plb.45.1688397314181; Mon, 03 Jul 2023 08:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688397314; cv=none; d=google.com; s=arc-20160816; b=HLzjVrgnGLodfkab6aqXfMmhohXlNe5Uhpt+TpJKFS59UNH8QJThGDwFanqLMjMcq6 n6zm/5WeQRcvQgnHqVTHjxgKEqU3QXDydqtBcoUsxDz25p2Xk1i6cd92BT22HCcl2EOP 44Sb/4G5Ughx1JJlTe5Eh6v5wz/+JCAb1AZJUdA9XrAphMPQDugQnpfRKf/0FOTGwUco /j02BDzUkG09EHHySoeCDofnKtGr9Sw/T0X+TPFAFD3/17uE2dvz84dRGq6s0Y6JvRK7 IgXCOT+MJLD0EQmJ4S3oDdqGrYkOLsO4a65MQgoaB4av8xdC3I1dWNuDNPQaMV6EyxFJ Hy4w== 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=gob2L9tWTmI3nDk3oZVLR+30JlTcWug7s7HdFaK5Nu8=; fh=wEKpKvKev9MIWer2LfA+vg/u4+mvwdpLl19UB+UhWgI=; b=MyXjwUg+zxfYvHRLNyXb9f7cgMNyHWoBDjesCFob3CTtUvqwMI3dR/8/3Q8JKIto1d ZV35Xl9ui168e5eFVihBCpk7/jUUYTYe3Gus50Xx8AUNlxj4Ft2NwRGTEOJatOCgq5W0 bylW2HjtVEZVHjZ3DsXnlel5aVzUc7kvea8/XMDxgmR5qjpBwr2oPRz8BwPNDE41816o CcnCc9V9bf+GDtQ/avucoeDWrgQllYcx6TIDa3ydtR8t2DErehUCTLl4gtygfe3KBmqe 3P4GHLcJNczmZDwy2b5i5IjdYNu1SPqx2Un5fjpwV0/Ne7WWOgFlVP5hqd1+Ehf3omO9 czaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R5XgUUKb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a170902dad000b001b89b5a460esi1705659plx.405.2023.07.03.08.15.00; Mon, 03 Jul 2023 08:15:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R5XgUUKb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231646AbjGCOz5 (ORCPT + 99 others); Mon, 3 Jul 2023 10:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231521AbjGCOzv (ORCPT ); Mon, 3 Jul 2023 10:55:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4A3AE6A for ; Mon, 3 Jul 2023 07:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688396107; 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=gob2L9tWTmI3nDk3oZVLR+30JlTcWug7s7HdFaK5Nu8=; b=R5XgUUKbM8LqcDdsmO2S8MQ5j8B1fpbmjuGCEjHVgvIav+IkuOUkj+W+tZj75eWFsb8N+6 ik/YhCkHaBg58Ql1BxA40MvrACyHdie1TOMgFcrl/Pdj5ChSwMFA+KgjucF5L1RWIchwaK qRtWubhjKaM2pphAw+PfWuPQuwAe4qs= 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-586-DkklPGDuPJG8HJR2y-BxoQ-1; Mon, 03 Jul 2023 10:55:04 -0400 X-MC-Unique: DkklPGDuPJG8HJR2y-BxoQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB5A38028B2; Mon, 3 Jul 2023 14:55:03 +0000 (UTC) Received: from [10.22.17.92] (unknown [10.22.17.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1812715230A0; Mon, 3 Jul 2023 14:55:03 +0000 (UTC) Message-ID: <5bc41342-5ba6-68e9-8315-9e5cef65d102@redhat.com> Date: Mon, 3 Jul 2023 10:55:02 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH] 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: <20230628211637.1679348-1-longman@redhat.com> <20230703102604.GC4253@hirez.programming.kicks-ass.net> From: Waiman Long In-Reply-To: <20230703102604.GC4253@hirez.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.7 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/3/23 06:26, Peter Zijlstra wrote: > On Wed, Jun 28, 2023 at 05:16:37PM -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. >> >> Before this patch, passing in an empty cpumask to sched_setaffinity(2) >> will return an EINVAL error. With this patch, an error will no longer >> be returned. Instead, the user_cpus_ptr that stores the user provided >> affinity, if set, will be cleared and the task's CPU affinity will be >> reset to that of the current cpuset. This reverts the cpumask change >> done by all the previous sched_setaffinity(2) calls. >> > This is a user visible ABI change -- but with very limited motivation. > Why do we want this? Who will use this? Yes, this is a visible ABI change, but it should be backward compatible as I doubt there are applications out there depending on the fact that passing an empty cpumask to sched_setaffinity() must return an error. Our OpenShift team has actually hit a problem with the recent persistent user provided cpu affinity change because they are relying on the fact that moving a task to a different cpuset will reset cpu affinity to the cpuset default which is no longer true. That is the main reason behind this patch to provide a way to reset cpu affinity to the cpuset default. I am thinking of requesting sched_setaffinity(2) manpage update to document the persistent user provided cpu affinity change and the way to reset it after this patch is merged upstream. Cheers, Longman