Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2455109rdh; Wed, 27 Sep 2023 03:15:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVcbl7Y2ES/ziGFZHZbmH4tPd1qlw6ZFjs6JsJX0eSbWgfzXrm+t3aT9xysWbTbZ3eCktu X-Received: by 2002:a1f:6283:0:b0:49a:317c:ba5f with SMTP id w125-20020a1f6283000000b0049a317cba5fmr1625816vkb.11.1695809735381; Wed, 27 Sep 2023 03:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695809735; cv=none; d=google.com; s=arc-20160816; b=LcXdOAkwfTHEurSnxRLsqNJVfPdAplmr5gRRIepy8ufKkcFq5jGIECGxQoNvTOS7tt 2obeCQP4GCBmnHdGN+bDoOiUX9ToA7bggN2/U1M9caHjVcrdRYVeK6jl7lhSTImHE+BJ I8oLzlXhhHRFAuHRY8m8ARPCOhaNOQfbFWl9Q/tGTE/JrknQjCvt/W/LzA+2OLI685/y UGNVA/0seO7p3L2x0RHZaFg23J3DmYifrFgn8fRsvDExgYyaFaSmJ/zLojLVh5KBQJyV Mj5IlTWGZpj0iLdkGODBcQ+xK6goqtmLhSJfYnue1CP8tSaM0JnpodjV6D2QiAGzV5S4 FjvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1JPRMkBEdyKk7oKqtMorRqkKFZiq/eCbKVfKVWvw/8s=; fh=tOpYinvITJLaZonVceMMJBIy7fronsdxbR2TIYPhEwI=; b=dhtWKEA90RW5/8x1gIbtWRI/eEFvq7OEqypeXtfICMNjEOld/G/keCoyW0YSSwrWB4 mDaX/d6O6C2C7Mvz5zE/N/JJ7MesnQlyVUAVlz9Uc+KShgCS0kDbiyZaVKSYg3SQ4LDT TO0BqGfakxm+bH0YwRw8PBRn8iILrBAPEqqI7okZPXQXQrc8UlsyzNoL0wTCpIdheAeA SpqQ05MPs3Nt3+EXzT+zC3eLQ2EE96OoHO90cx9FCS32ppyCCv0O3q2o1SYYbjuctE0/ ++hkhxvWnlMhOMWaHze9N7cGKfmVPyQF4HAaKe5JHnythhPnp0s2sxj+Xd9f4qofdtZe r7Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=j4f7qUPE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id p24-20020a056a0026d800b0068fe810e8a2si14349740pfw.185.2023.09.27.03.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 03:15:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=j4f7qUPE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 48D9F81C4AAF; Tue, 26 Sep 2023 23:58:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229907AbjI0G6o (ORCPT + 99 others); Wed, 27 Sep 2023 02:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbjI0G6m (ORCPT ); Wed, 27 Sep 2023 02:58:42 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E9B7D6; Tue, 26 Sep 2023 23:58:41 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38QLTNqi006223; Wed, 27 Sep 2023 06:58:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-03-30; bh=1JPRMkBEdyKk7oKqtMorRqkKFZiq/eCbKVfKVWvw/8s=; b=j4f7qUPE1xQaJtTa6nZl4W//hfXjWP5a2DFCPZl8T0jADiS8+vk+ZlihvKPLWcndWMDR Io99PmShvV3XhYzlX9ToHqCUbz3Jbsk7DSwMOdZqem/pFY3tYzdT584CxVORSTojonz4 NB32mTuF0HPRr+J5G10VoYlxUDcF6l/J2GItREUnlJfN1puMP3GaH4cwQy84KxCeBZbM omffYvkUO2xYO+AofidEXUfZ9qoBPZbSX9C4fkZ0kyOsn25EmBVNOCFsPCzaRMmimFYD vBOJQAYCoj93OdOnBvpG+dacfNDwgplgn35foQRey2IleSHdCzuaJO6+swavPa1B7zYk dA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9pxc0pjg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Sep 2023 06:58:07 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 38R6CI0V030811; Wed, 27 Sep 2023 06:58:06 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t9pfdd2yg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Sep 2023 06:58:05 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 38R6u0dh023218; Wed, 27 Sep 2023 06:58:05 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3t9pfdd2xb-1; Wed, 27 Sep 2023 06:58:05 +0000 From: Harshit Mogalapalli To: Waiman Long , Zefan Li , Tejun Heo , Johannes Weiner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org, error27@gmail.com, harshit.m.mogalapalli@oracle.com, kamalesh.babulal@oracle.com, kernel test robot Subject: [PATCH next] cgroup/cpuset: Cleanup signedness issue in cpu_exclusive_check() Date: Tue, 26 Sep 2023 23:58:01 -0700 Message-ID: <20230927065801.2139969-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-27_03,2023-09-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309270058 X-Proofpoint-GUID: TdBcfUHpmIQ-MCe_6iUo7Dn4JgRp97J1 X-Proofpoint-ORIG-GUID: TdBcfUHpmIQ-MCe_6iUo7Dn4JgRp97J1 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Tue, 26 Sep 2023 23:58:51 -0700 (PDT) Smatch complains about returning negative error codes from a type bool function. kernel/cgroup/cpuset.c:705 cpu_exclusive_check() warn: signedness bug returning '(-22)' The code works correctly, but it is confusing. The current behavior is that cpu_exclusive_check() returns true if it's *NOT* exclusive. Rename it to cpusets_are_exclusive() and reverse the returns so it returns true if it is exclusive and false if it's not. Update both callers as well. Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202309201706.2LhKdM6o-lkp@intel.com/ Signed-off-by: Harshit Mogalapalli --- This is based on sattic analysis, only compile tested --- kernel/cgroup/cpuset.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 15f399153a2e..afefddd33c3e 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -719,18 +719,18 @@ static inline struct cpumask *fetch_xcpus(struct cpuset *cs) } /* - * cpu_exclusive_check() - check if two cpusets are exclusive + * cpusets_are_exclusive() - check if two cpusets are exclusive * - * Return 0 if exclusive, -EINVAL if not + * Return true if exclusive, false if not */ -static inline bool cpu_exclusive_check(struct cpuset *cs1, struct cpuset *cs2) +static inline bool cpusets_are_exclusive(struct cpuset *cs1, struct cpuset *cs2) { struct cpumask *xcpus1 = fetch_xcpus(cs1); struct cpumask *xcpus2 = fetch_xcpus(cs2); if (cpumask_intersects(xcpus1, xcpus2)) - return -EINVAL; - return 0; + return false; + return true; } /* @@ -833,7 +833,7 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) cpuset_for_each_child(c, css, par) { if ((is_cpu_exclusive(trial) || is_cpu_exclusive(c)) && c != cur) { - if (cpu_exclusive_check(trial, c)) + if (!cpusets_are_exclusive(trial, c)) goto out; } if ((is_mem_exclusive(trial) || is_mem_exclusive(c)) && @@ -1864,7 +1864,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd, cpuset_for_each_child(child, css, parent) { if (child == cs) continue; - if (cpu_exclusive_check(cs, child)) { + if (!cpusets_are_exclusive(cs, child)) { exclusive = false; break; } -- 2.41.0