Received: by 10.192.165.156 with SMTP id m28csp657665imm; Mon, 16 Apr 2018 06:44:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/lPWtGJkMFkll0Y214AJsGsr6S7G9LjT1uDJJDAlxJT5lVOQb38fG4Ue+PKumgdkVMr33X X-Received: by 10.101.93.82 with SMTP id e18mr13319853pgt.123.1523886262455; Mon, 16 Apr 2018 06:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523886262; cv=none; d=google.com; s=arc-20160816; b=d4hKbLoFKkWz3J6fdJPIaNcZ+WX78Jilqm96qKjjsHKmotgIFDEefEsVLzG+cE+Wkn yPbMlJULPgK6r9re+lNVvxgX7fSmmddsmYBwU8dJOOXn6SJFFZwUhploizPdBa72FeYt 5zFFMyILXCT+4RxISsYXOwFmv7XF2aMTi0BOSuXkzCit+NrGiEr/rd0AszW+P5PNvBpF rmh81z20B3rBiVO1tnpCOINPYEhYj5xz7jl2uzucBeqkv25oxPJpMrJmDkSLTRUvqt1G NIkRmlr/ZZOb1EtMEGmfdoP+NFLKjJM1zQFqm1xRHapaYLuIEaXj4asWHsrMBTWb+sLU DZuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=RK+KQEfzgeTcUsWNJBhMpWUoDcg+VA2Hur+YPJ5xkYU=; b=ak0jArKnGVgr3ausw27ZT56gTGvwNcoudnlqQMH/JHdaZpJaC+mVXXav+BFPC2QeZb 4Qkspp5yHFcNKkK93UOBAVEFn3PphWlqs/iDgaMPAKrGL1lSPcZY5TpMdqenSunqSKaN xLVWLMl837eIGuwg/WkEVJsvsHQv9lzggowNGi3DRdOOfF5g/xNMq0VbhjnhcEzTgGMe OgdH3B3OgrC2WG6r2+lt1UmwL5iw/nOPIu6oVMTy9d1QfYd1Y7OIxBRn9zCGTdUGVi4h oupeUI8to32k9AqV7lhlLnyalF57WY5Lvc58SR/qpfzsspTVtJnLwSGurIS5t+uQcpuf kEqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=jQuow5ey; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si1846482pge.5.2018.04.16.06.44.08; Mon, 16 Apr 2018 06:44:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=jQuow5ey; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755168AbeDPNmn (ORCPT + 99 others); Mon, 16 Apr 2018 09:42:43 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:39994 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755108AbeDPNml (ORCPT ); Mon, 16 Apr 2018 09:42:41 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3GDaP4M177890; Mon, 16 Apr 2018 13:42:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=RK+KQEfzgeTcUsWNJBhMpWUoDcg+VA2Hur+YPJ5xkYU=; b=jQuow5eygn5NJlfeXCHzFSDM/fwHMjjUvBAK1tOcYRAr5IErScpZ6cXLOyJN7hR7UQzL 0ezi12uHtLEMzRb7cuVP8MiLkdP0p+MSB5OACLsj7PnwTlHzQk7e1l4vbjzrmSJN+aAP iGZFmJ3jsAqADLnE1g2GvLCEVq2TR2fV4N2fqsN05XCh+E5AdNF0zX5poiqeSwtgfVnF VGmk5PUKcRZ2cRuzbKBl7qnKjrJDsbzs2oZjOfyWB9jnGgT+Y28KHDS3fFckw3Y9f06x DQ2isfwVG9pVib6dm+aaPmta6TcXOYyrOpqsf5as/3rVbm6+T6MLXUl1JrBqBKxhjH5U dQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2hbamew4xp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Apr 2018 13:42:18 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w3GDgHmV025539 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Apr 2018 13:42:17 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w3GDgGQ6030016; Mon, 16 Apr 2018 13:42:16 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Apr 2018 06:42:15 -0700 Date: Mon, 16 Apr 2018 16:42:03 +0300 From: Dan Carpenter To: James Simmons Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Oleg Drokin , NeilBrown , Dmitry Eremin , Linux Kernel Mailing List , Lustre Development List Subject: Re: [PATCH 01/25] staging: lustre: libcfs: remove useless CPU partition code Message-ID: <20180416134203.ehtebtyes34p2tsm@mwanda> References: <1523851807-16573-1-git-send-email-jsimmons@infradead.org> <1523851807-16573-2-git-send-email-jsimmons@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1523851807-16573-2-git-send-email-jsimmons@infradead.org> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8864 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=973 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804160130 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 16, 2018 at 12:09:43AM -0400, James Simmons wrote: > @@ -1033,6 +953,7 @@ static int cfs_cpu_dead(unsigned int cpu) > #endif > ret = -EINVAL; > > + get_online_cpus(); > if (*cpu_pattern) { > char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL); > > @@ -1058,13 +979,7 @@ static int cfs_cpu_dead(unsigned int cpu) > } > } > > - spin_lock(&cpt_data.cpt_lock); > - if (cfs_cpt_table->ctb_version != cpt_data.cpt_version) { > - spin_unlock(&cpt_data.cpt_lock); > - CERROR("CPU hotplug/unplug during setup\n"); > - goto failed; > - } > - spin_unlock(&cpt_data.cpt_lock); > + put_online_cpus(); > > LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n", > num_online_nodes(), num_online_cpus(), > @@ -1072,6 +987,7 @@ static int cfs_cpu_dead(unsigned int cpu) > return 0; > > failed: > + put_online_cpus(); > cfs_cpu_fini(); > return ret; > } When you have a one label called "failed" then I call that "one err" style error handling and it's the most bug prone style of error handling to use. Always be suspicious of code that uses a "err:" labels. The bug here is typical. We are calling put_online_cpus() on paths where we didn't call get_online_cpus(). The best way to do error handling is to keep track of each resource that was allocated and then only free the things that have been allocated. Also the label name should indicate what was freed. Generally avoid magic, opaque functions like cfs_cpu_fini(). As a reviewer, it's harder for me to check that cfs_cpu_fini() frees everything correctly instead of the a normal list of frees like: free_table: cfs_cpt_table_free(cfs_cpt_table); free_hotplug_stuff: cpuhp_remove_state_nocalls(lustre_cpu_online); set_state_dead: cpuhp_remove_state_nocalls(CPUHP_LUSTRE_CFS_DEAD); When I'm reading the code, and I see a "goto free_table;", I only need to ask, "Was table the most recently allocated resource?" If yes, then the code is correct, if no then it's buggy. It's simple review. regards, dan carpenter