From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59383E7B5F9 for ; Wed, 4 Oct 2023 12:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233104AbjJDMU4 (ORCPT ); Wed, 4 Oct 2023 08:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233226AbjJDMUy (ORCPT ); Wed, 4 Oct 2023 08:20:54 -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 81770C6 for ; Wed, 4 Oct 2023 05:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696422002; 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=eCki2r9Bn0BuFn05o7Il1NR+6SHO0CDb++6+9dm7szM=; b=YkMHm7iN/f7EWjHqDR2EqRDVAhyB5DXVN39FYCIc5GNjjdTJOxqxpFVqmUuFb4L6NMzrJc aCANj65FdLPmGUN5OJ+6FnjE6DS+SbsokfOJCqvn5R31/cSXMLUNsjVisnmxan+4hF5QQ9 /byMPT1egxTsc9UzynXXu170/BEPuIw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-1-CxTm9tFtPCqpzMCnO1N7AQ-1; Wed, 04 Oct 2023 08:20:00 -0400 X-MC-Unique: CxTm9tFtPCqpzMCnO1N7AQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 501E23806739; Wed, 4 Oct 2023 12:19:59 +0000 (UTC) Received: from [10.22.32.136] (unknown [10.22.32.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78670C15BB8; Wed, 4 Oct 2023 12:19:58 +0000 (UTC) Message-ID: <7a7bc23f-be01-d06a-42d2-a2a121577b09@redhat.com> Date: Wed, 4 Oct 2023 08:19: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 v4] sched/core: Use zero length to reset cpumasks in sched_setaffinity() Content-Language: en-US To: Ingo Molnar , 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 , Florian Weimer References: <20231003205735.2921964-1-longman@redhat.com> <20231004083648.GI27267@noisy.programming.kicks-ass.net> <20231004094330.GL1539@noisy.programming.kicks-ass.net> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/4/23 06:06, Ingo Molnar wrote: > * Peter Zijlstra wrote: > >> On Wed, Oct 04, 2023 at 11:23:41AM +0200, Ingo Molnar wrote: >> >>>> if (user_mask) { >>>> - cpumask_copy(user_mask, in_mask); >>>> + /* >>>> + * All-set user cpumask resets affinity and drops the explicit >>>> + * user mask. >>>> + */ >>>> + cpumask_and(user_mask, in_mask, cpu_possible_mask); >>>> + if (cpumask_equal(user_mask, cpu_possible_mask)) { >>>> + kfree(user_mask); >>>> + user_mask = NULL; >>>> + } >>> Question: is there any observable behavioral difference between current >>> (old) all-set cpumask calls and the patched (new) one? >> Very little I think -- the main difference is that we no longer carry >> the ->user_cpus_ptr mask around, and that saves a little masking. > So calling with a full mask would actually work fine on 'old' kernels too, > as it's a 'reset' event in essence. (With a bit of allocation & masking > overhead.) > > This pretty unambiguously marks the full-mask solution as the superior ABI ... I am fine with that one too. I do have a little bit concern about that the difference in behavior when the full mask is passed in, but that is reverting to the old behavior before commit 8f9ea86fdf99 ("sched: Always preserve the user requested cpumask"). BTW, we can probably check the in_mask directly earlier to skip an unnecessary cpumask allocation and free in this particular case. Cheers, Longman