From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hZHZiXpi" 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