From nobody Tue Dec 2 02:04:08 2025 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 181ED34B18C for ; Thu, 20 Nov 2025 14:57:26 +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=1763650648; cv=none; b=Tn0MQNWYOKwhsIKVWrs8wzY9yfoZdTnJC9I6aY1H0SnIQualDackM4skqGXUvkE9i0+LaFpYlZ53O3fXl4aPW29wFk8evvvMc4qTqcHbhuAKVAT0iQfIq54s4r5TIKcP1bcmG+rajHqoxcFDKJUx/Guuj0v8Cwq2Qac8YWBkny4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763650648; c=relaxed/simple; bh=GjD9QEs7SzmnvHl3zPU+QeUV23iO3Qc9hI+AkOrFEL0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AceQyTe+LS9POVHQRYG/qnWN8Ol8qq36ZLE1VyoYSY5XUR2PffsR3xx/0uGI4X9iAU325vcBq1Ee7Esh3UzcWlQzyD/9F4coMocvsMUHWTma/hHUeAWqIqM56NdaMwAEh2dWcjf1uVron2mb+Le8/0YfiOZQp6Pc8fG5K5oD4Ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=Dpu/ieQV; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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="Dpu/ieQV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763650646; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M2+7kEHxFbK67aWdgfs3yD8hYiWGLMLm6j7NkVaF+ig=; b=Dpu/ieQVr8iOhVZ/KY1DUjJJchplfapP8032J7h/wgXSH/WZq6qxazxhiaittDPclZB1GY Buod9wMpXEMCvF1vvwkECALYSKPXBv8XObOpuCBLhX0fXCzKLc3vYvD/Svb3fFaSjAyxv3 vcHqmQmRvzQLjKvyHVS7uKwjrTiGyNk= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-184-UucdNpW6PJ6dnkWHQVC0Qw-1; Thu, 20 Nov 2025 09:57:22 -0500 X-MC-Unique: UucdNpW6PJ6dnkWHQVC0Qw-1 X-Mimecast-MFC-AGG-ID: UucdNpW6PJ6dnkWHQVC0Qw_1763650641 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 53A3B1800451; Thu, 20 Nov 2025 14:57:21 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.45.224.239]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 741311940E82; Thu, 20 Nov 2025 14:57:18 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Waiman Long Cc: Yury Norov , Gabriele Monaco Subject: [PATCH v16 6/7] cpumask: Add initialiser to use cleanup helpers Date: Thu, 20 Nov 2025 15:56:52 +0100 Message-ID: <20251120145653.296659-7-gmonaco@redhat.com> In-Reply-To: <20251120145653.296659-1-gmonaco@redhat.com> References: <20251120145653.296659-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" From: Yury Norov Now we can simplify a code that allocates cpumasks for local needs. Automatic variables have to be initialized at declaration, or at least before any possibility for the logic to return, so that compiler wouldn't try to call an associate destructor function on a random stack number. Because cpumask_var_t, depending on the CPUMASK_OFFSTACK config, is either a pointer or an array, we have to have a macro for initialization. So define a CPUMASK_VAR_NULL macro, which allows to init struct cpumask pointer with NULL when CPUMASK_OFFSTACK is enabled, and effectively a no-op when CPUMASK_OFFSTACK is disabled (initialisation optimised out with -O2). Signed-off-by: Yury Norov Signed-off-by: Gabriele Monaco Reviewed-by: Frederic Weisbecker --- include/linux/cpumask.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index ff8f41ab7ce6..68be522449ec 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -1005,6 +1005,7 @@ static __always_inline unsigned int cpumask_size(void) =20 #define this_cpu_cpumask_var_ptr(x) this_cpu_read(x) #define __cpumask_var_read_mostly __read_mostly +#define CPUMASK_VAR_NULL NULL =20 bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node); =20 @@ -1051,6 +1052,7 @@ static __always_inline bool cpumask_available(cpumask= _var_t mask) =20 #define this_cpu_cpumask_var_ptr(x) this_cpu_ptr(x) #define __cpumask_var_read_mostly +#define CPUMASK_VAR_NULL {} =20 static __always_inline bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t f= lags) { --=20 2.51.1