Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5015794rdb; Tue, 12 Dec 2023 16:56:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk/TY2mkOOYwwFGdE68Bx2VKNe8LxR6ZNBIgG7GKKfUtWsReHBzn1hU2GMKvYlhPK8kByG X-Received: by 2002:a05:6808:23d4:b0:3b9:ed25:fd50 with SMTP id bq20-20020a05680823d400b003b9ed25fd50mr8884309oib.59.1702429014659; Tue, 12 Dec 2023 16:56:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702429014; cv=none; d=google.com; s=arc-20160816; b=yMTHae4IYtHyomb5s+PrIGHIVJX4M+wLF4R4MaaWOfdHEKkwVLcSJzn8knt6nyBW1y QDeZw/MDtKBUvq2rlT7b7U9g/dZOkeXlLKElCElAGXT4xyOOEwFz1/uI6dD/yJrRGmKM 4Rj3TINctbOSXsgNG8HRYblgrcSh9sBE+MMXl0gyjWajfuLUL3WC54GsK9a5uDWWBqVQ FxnuZ8C+s81P2hM33Y41uu0Vd7BfsB1hZLCk4Ifjxb7bqENofqertlgI2kcWCJkuKHvW hJv55ZrAOUHcmJkb1+52lk4riW515OYtv7NyQUgzJsUpT+DX7dsKddMDhnjG5tzFUem2 Nskg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GaNuNCakBQBQrzCKcC0GSD8P31f5TqLSevRyrBQw0D0=; fh=BDL/a/ouV+t/CAyBcvNlMEmOkYdq8S2Mf5MVqbnjn8c=; b=pRWK8pUjR4Jz+1lm+SJAYbI8Z99cWH8dd38irCHTK225mRUwBIfJJbDpgxf467Ns7F +VEpH05Sgu90ivhwufKeKlCZFSiqxbeM0z8sG3peEkm2u58+AUEXUDooUkfOwQhIKdW0 wx41A3R0HLwmsodkuobYHM9jJLH5ObaPcoFniUZnWLjwuR0YWjJ6lxXj7jyCeiggnt+f kg6oylbVSahKWSIQhlObbLIQFqb3htrpuvvOEJVEI3hB+XWUyoHWm7mB6gc2XrrWvLc2 ZvuRDEvBFIelqLe0cW5WBqYndHaENDpvyplwfJXc/nAFsEQYKAsrLCfRNsAcqK8Fzqu7 +TMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cXCzgTVJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b1-20020a056a00114100b006ce702e8930si8638218pfm.215.2023.12.12.16.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 16:56:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cXCzgTVJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0D86E8098627; Tue, 12 Dec 2023 16:56:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378066AbjLMA42 (ORCPT + 99 others); Tue, 12 Dec 2023 19:56:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235189AbjLMA41 (ORCPT ); Tue, 12 Dec 2023 19:56:27 -0500 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 F3BD3CD for ; Tue, 12 Dec 2023 16:56:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702428992; 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: in-reply-to:in-reply-to:references:references; bh=GaNuNCakBQBQrzCKcC0GSD8P31f5TqLSevRyrBQw0D0=; b=cXCzgTVJu6bXTirvPDqxf3zHFlTdtSLpVZLt0Fw+R3P98tkYVjrPJq+q4QXEzliXsu5iel UYg4NhgaUiuavPd1Hk9kt3nI9bFhZQrsmjd5vclRYYJ3QL5nA355G7xNIHCzTl4IaPpKmb 1Ac3dc0qYlmFDO0tXpQzxz6PprLJPwA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-rxSLypz5MPGg2IXSVqwzzg-1; Tue, 12 Dec 2023 19:56:25 -0500 X-MC-Unique: rxSLypz5MPGg2IXSVqwzzg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 63B93386A0A6; Wed, 13 Dec 2023 00:56:25 +0000 (UTC) Received: from fedora (unknown [10.72.116.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 214C42166B31; Wed, 13 Dec 2023 00:56:21 +0000 (UTC) Date: Wed, 13 Dec 2023 08:56:18 +0800 From: Ming Lei To: Yury Norov Cc: Andrew Morton , Thomas Gleixner , linux-kernel@vger.kernel.org, Andy Shevchenko , Rasmus Villemoes Subject: Re: [PATCH v3 5/7] lib/cgroup_cpus: don't zero cpumasks in group_cpus_evenly() on allocation Message-ID: References: <20231212042108.682072-1-yury.norov@gmail.com> <20231212042108.682072-6-yury.norov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212042108.682072-6-yury.norov@gmail.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 12 Dec 2023 16:56:52 -0800 (PST) On Mon, Dec 11, 2023 at 08:21:05PM -0800, Yury Norov wrote: > nmsk and npresmsk are both allocated with zalloc_cpumask_var(), but they > are initialized by copying later in the code, and so may be allocated > uninitialized. > > Signed-off-by: Yury Norov > --- > lib/group_cpus.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/group_cpus.c b/lib/group_cpus.c > index cded3c8ea63b..c7fcd04c87bf 100644 > --- a/lib/group_cpus.c > +++ b/lib/group_cpus.c > @@ -347,10 +347,10 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps) > int ret = -ENOMEM; > struct cpumask *masks = NULL; > > - if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL)) > + if (!alloc_cpumask_var(&nmsk, GFP_KERNEL)) > return NULL; `nmsk` is actually used by __group_cpus_evenly() only, and it should be local variable of __group_cpus_evenly(), can you move its allocation into __group_cpus_evenly()? > > - if (!zalloc_cpumask_var(&npresmsk, GFP_KERNEL)) > + if (!alloc_cpumask_var(&npresmsk, GFP_KERNEL)) > goto fail_nmsk; The above one looks fine, especially `npresmsk` is initialized in group_cpus_evenly() explicitly. Thanks, Ming