Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6094801rdb; Mon, 1 Jan 2024 08:27:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEekkTXSHEDFnANdx5CrSuT582ONDI2upTgGh1CH7zlsiL3spvuh1dhpjC8Wc9qXlVXdprh X-Received: by 2002:a05:6808:2f07:b0:3bb:c0d1:b4b with SMTP id gu7-20020a0568082f0700b003bbc0d10b4bmr13570977oib.43.1704126438827; Mon, 01 Jan 2024 08:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704126438; cv=none; d=google.com; s=arc-20160816; b=bjJ12dD8J7/e9DDA+SN+abEEDcyJiOCxR5QQGj/gMExZgnWhmNe0vNz668sgZlGTY1 DHIgEOXGGdVfCmWYHfx/MBoV3j3BMubiQnLpfY/e/xmE3rSmLqilLTpjuxyOHHOlbE1t 9z6TIt6R/MLmF1JD+5qw9zUejI+MDYTKfmmjRAlLYJhO0D+xWv4WB8oBxa25ag7JT8wR aQQUM9bPQz22xu6GVXIQsWFpZc/C8oNv69sjNkVDqMEGADXbkFoRy2L2etsRXjBAZIrG kft1/mY2TBLFj9UkRA5RNgutosYO40u7lhpPZdzotSDzOL1sCM/jipjQ6+v4DtcGk7EU n/5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=fHJuaOOoMITcmaF/jJKQveH0rmkD/J9cEtpvvbiUPHE=; fh=h2yDiJzBulgH3P6QCmwkvPj3UDsmaKn0KyWD1T/JNPw=; b=povP8Ga1LmwuyaPBHFRReeRYOZNBjTxCADO442ETphB+dUa+v4B5hPLQLowz3EirHR 77IijA41HSrklnlH+p4veR1PeGTMdEPLmbplbO5bEvysiQPJni6p6/OK34E/AQVCAUP6 yvK3MxvyaCqa3RZDBdtIpA9+3ndTkSs43zNJ/fKl81kt+OT2xOdJJkV/X6FBlsiNped1 hMgEvecIIgw9q4T5t0T2OsTMwZfaeX0AMsbYwcna+kr6zHF03IOWMYqCQ+HSI8nhf/f9 HMdFBrjtM2NxH277p1puRQcsET+v2YOE2aGfz2w5Hw1Njx8mTrtCiK9PvM3on4MeNYCO QYtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WrCyt+Ka; spf=pass (google.com: domain of linux-kernel+bounces-13904-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13904-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 n51-20020a056a000d7300b006bbfc944748si13910729pfv.315.2024.01.01.08.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 08:27:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13904-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=WrCyt+Ka; spf=pass (google.com: domain of linux-kernel+bounces-13904-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13904-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 6FA04281ECB for ; Mon, 1 Jan 2024 16:27:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5CAD8F7E; Mon, 1 Jan 2024 16:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WrCyt+Ka" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 727148F68 for ; Mon, 1 Jan 2024 16:27:03 +0000 (UTC) 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=1704126422; 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=fHJuaOOoMITcmaF/jJKQveH0rmkD/J9cEtpvvbiUPHE=; b=WrCyt+KaLMhLINXSSsr9+Fo6jtUe0HuJ/E0siYguvUL+mEgdGBEk24Xb8lyWFNxr9YVgMu AGy15SxMfyYXHgLvqbg0IaAbeLyTJvc7bEZn8TmM2Rd7TusyRpiTV8ER5Uvo5NZOnTCJAh 3FxYbYSvkBjBcDWL9yHsshTzxG9gk6Q= 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-691-EbaG0ZwFMgeB8Eg_Jyl7kA-1; Mon, 01 Jan 2024 11:26:59 -0500 X-MC-Unique: EbaG0ZwFMgeB8Eg_Jyl7kA-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 B9E8B83FC22; Mon, 1 Jan 2024 16:26:58 +0000 (UTC) Received: from [10.22.32.137] (unknown [10.22.32.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11B96492BF0; Mon, 1 Jan 2024 16:26:58 +0000 (UTC) Message-ID: <86fa9afa-21c0-42fb-926d-5ffc69695d30@redhat.com> Date: Mon, 1 Jan 2024 11:26:57 -0500 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] cgroup/cpuset: Adjust exception handling in generate_sched_domains() Content-Language: en-US To: Markus Elfring , cgroups@vger.kernel.org, kernel-janitors@vger.kernel.org, Johannes Weiner , Tejun Heo , Zefan Li Cc: LKML References: <53be5f98-6359-48b5-955e-fd203d99d3cb@web.de> <9cd1ce1d-15c7-427c-9929-f3c75b97b49c@redhat.com> 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 1/1/24 03:56, Markus Elfring wrote: >>> Two resource allocation failures triggered further actions >>> over the label “done” so far. >>> >>> * Jump to the statement “ndoms = 1;” in three cases directly >>>    by using the label “set_ndoms” instead. >>> >>> * Delete an assignment for the variable “ndoms” in one if branch. > … >>> --- >>>   kernel/cgroup/cpuset.c | 8 ++++---- >>>   1 file changed, 4 insertions(+), 4 deletions(-) > … >>> @@ -973,10 +973,9 @@ static int generate_sched_domains(cpumask_var_t **domains, >>> >>>       /* Special case for the 99% of systems with one, full, sched domain */ >>>       if (root_load_balance && !top_cpuset.nr_subparts) { >>> -        ndoms = 1; >>>           doms = alloc_sched_domains(ndoms); >>>           if (!doms) >>> -            goto done; >>> +            goto set_ndoms; >>> >>>           dattr = kmalloc(sizeof(struct sched_domain_attr), GFP_KERNEL); >>>           if (dattr) { > … >>> @@ -1123,6 +1122,7 @@ static int generate_sched_domains(cpumask_var_t **domains, >>>        * See comments in partition_sched_domains(). >>>        */ >>>       if (doms == NULL) >>> +set_ndoms: >>>           ndoms = 1; >>> >>>       *domains    = doms; > … >> Please clarify what this patch is for. Is it just a cleanup with no functional changes or is there a bug that is being fixed? > The development opinions might vary for the presented transformation. > I suggest to reconsider the number of relevant variable assignments here. > Would you categorise an extra statement still as a desirable implementation detail? My understanding of the patch is just to avoid an unnecessary call to kfree() as kfree(NULL) is basically a NOP. By jumping inside the "if" part of the conditional statement, however, it makes it a bit harder to read. As generate_sched_domains() is not in the fast path, I would rather have a patch that can simplify the logic than to make it harder to understand. Cheers, Longman