Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp919631lqo; Wed, 8 May 2024 21:47:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcxe2AEjOUKxu1MbgYnF30Ygb2D2pZIALI0sCy7vtjhGQ3I/497pKsa9/DcRVnC3aUaB23LSe5nnPiHcQgmCIfqvMCMrto+TvSXjPlag== X-Google-Smtp-Source: AGHT+IHNKlaa7COeQPxoKIeDzMJjQU+4RykQ/gW/a3rvnNtniPWyuIMzEi+V8ehezV066vhxzsN2 X-Received: by 2002:a17:90a:d389:b0:2b6:22f0:844c with SMTP id 98e67ed59e1d1-2b622f084b7mr3909516a91.36.1715230044849; Wed, 08 May 2024 21:47:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715230044; cv=pass; d=google.com; s=arc-20160816; b=JU4vkUCkZ1WFbeKilruJMZR9wB4jlSlUW8v6tx5WE8xONO2d2uRCdiSAPaOzGW+KZT eMiEtgHprnzaraf3cxXUnrJjJCCxag7+xRsQ97Wt0jAIbr3FOmOAxva//YT/OsPNT5kl LpeMeG0sEVOQP1vViauqZ1t6K1NJ5aTufvOGqHC2Ux3nhQFULOwqFi26FGToArj6fr1V 9bP6n+KOR5OOMX+SqTeKHANsz/fMSFN5BNHo/QAsE0m8zNNdz32wAUeXDFSvsPUfdEhE Tj2V8YD7FLzT3Lv9ERwTDFZPmr+Nfg5Ez76tbFf7iztU91vK0G1aJzi1n4e2vEAgQVPT nkcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=UiDkouuHBxEQ48cCxAAxKmsT/M+EhKgEfBASxmW5rGA=; fh=SiPjK4fKljf8No+/me0kw1zKp9F2/WHVf6RgzRDKu6U=; b=NzIfOmsga0C39nheEvmQOZxuNZXpRIGOHZU/eTgB62lGfIbj9iMCwNhORNo8U8mDRp hHfdQP9BprAf/vRhIT+VED2ZWactnEZtfG71WSaIi7/YpftutP/jnMh1I6d/nG7DvngE 77KtMI6btnkfh80fX2eQqWZcVkrj9Z4iMgnBLc934e1mxY8BZSgYLBsk41G6EFAVMKYc jyC/mLrbxDE/72XrBzu6e4JFSSEcJPbhH0gVQpVP3NP6gVPfmDwmW0j1auDtgSDa2hDY ga2sayBerZ4hDesmbnPfh21P/LZtncEgymAIkZMTrdrXyU6xJSgfnGnETZYeQI4HYgUa WMXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hZHZiXpi; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-174133-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174133-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628ea7535si2648883a91.95.2024.05.08.21.47.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 21:47:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174133-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hZHZiXpi; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-174133-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174133-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7E589281CA8 for ; Thu, 9 May 2024 04:47:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 681ED149003; Thu, 9 May 2024 04:47:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hZHZiXpi" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 208682747D for ; Thu, 9 May 2024 04:47:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715230033; cv=none; b=blZ+06BBcc/zazM9+qQUkhLUfV7RBQKZEe51R0tdAmIypSKUQGJqDFsIpCHrXvWZn0OU6YLv+mVHKSLXLxaq5m0LKDnsBNxEZ1DHwg4SwlkAnK5oK4jvYaRPrT6g9UrSO0FJntCcKvTSul0uZmHa0rTD/sm0yr60WPk9J+VZnZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715230033; c=relaxed/simple; bh=buoPxiUYl4Q0c2MkWof6PRlmVIB+2DTKwveRiixfmSE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=H/6eD9hH7IBCW6Bvu0CWhCjgWwKRRBV9Qb8+SKeVBgNBrnECB6YTnfNtw6fvdedBd/rAbXFXtZvLCdGDijO6+abhYRPTVVFUNvDkqoAPwg2dBUjjAW+HkDfgZp3ZGo+eVLCc9hTP53WMQdxEOmMtX2XuLLP+Qy+rhRUr28zzWNc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hZHZiXpi; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715230030; 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=UiDkouuHBxEQ48cCxAAxKmsT/M+EhKgEfBASxmW5rGA=; b=hZHZiXpim9xsMXgv8pfV1hGA0eBILi5vFzShg7jKQRU+WU83LrytbJDpHf9qOwpwDRxJmC AY3gwoWeppquG78Lud3qSvueMpv/xnFAltv0wb0HFcPWfEYdyLf3mSFGSyoOlByoNkYWuN /1koHjqfFKGhvrxvNTZQLAlc9dqSE2U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-W2BasM1vOn6Wfduln_v98Q-1; Thu, 09 May 2024 00:47:04 -0400 X-MC-Unique: W2BasM1vOn6Wfduln_v98Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C613A8007BC; Thu, 9 May 2024 04:47:03 +0000 (UTC) Received: from [10.22.32.103] (unknown [10.22.32.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E8F7492CAB; Thu, 9 May 2024 04:47:02 +0000 (UTC) Message-ID: Date: Wed, 8 May 2024 13:01:58 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sched/proc: Print user_cpus_ptr for task status To: Xuewen Yan Cc: Peter Zijlstra , Xuewen Yan , akpm@linux-foundation.org, oleg@redhat.com, dylanbhatch@google.com, rick.p.edgecombe@intel.com, ke.wang@unisoc.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org References: <20240429084633.9800-1-xuewen.yan@unisoc.com> <20240429121000.GA40213@noisy.programming.kicks-ass.net> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 On 5/7/24 02:57, Xuewen Yan wrote: >> These changes essentially reverts commit 851a723e45d1c("sched: Always >> clear user_cpus_ptr in do_set_cpus_allowed()") except the additional >> caller in the cpuset code. >> >> How about the following less invasive change? >> >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >> index 7019a40457a6..646837eab70c 100644 >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -2796,21 +2796,24 @@ __do_set_cpus_allowed(struct task_struct *p, >> struct affinity_context *ctx) >> } >> >> /* >> - * Used for kthread_bind() and select_fallback_rq(), in both cases the user >> - * affinity (if any) should be destroyed too. >> + * Used for kthread_bind() and select_fallback_rq(). Destroy user affinity >> + * if no intersection with the new mask. >> */ >> void do_set_cpus_allowed(struct task_struct *p, const struct cpumask >> *new_mask) >> { >> struct affinity_context ac = { >> .new_mask = new_mask, >> .user_mask = NULL, >> - .flags = SCA_USER, /* clear the user requested mask */ >> + .flags = 0, >> }; >> union cpumask_rcuhead { >> cpumask_t cpumask; >> struct rcu_head rcu; >> }; >> >> + if (current->user_cpus_ptr && >> !cpumask_intersects(current->user_cpus_ptr, new_mask)) > Thanks for your suggestion, and I try it and as for me, it works well, > but I change the "current" to p. > I think “current” is inappropriate because what is changed here is the > mask of p. > It is possible that “p” and “current” are not equal. > > I would send the next patch later and add your Suggested-by. Thanks > again for your advice! You are right. It should be "p" instead of "current". Thanks, Longman