Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp101244imm; Fri, 6 Jul 2018 14:56:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdaXS+AxfrfsDqnuZLskVWcdGeC1fqnBV4T367pMzpzaKvfOeuwXpUkZfn3Clsx2b81DTYx X-Received: by 2002:a65:638a:: with SMTP id h10-v6mr10879284pgv.269.1530914166454; Fri, 06 Jul 2018 14:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530914166; cv=none; d=google.com; s=arc-20160816; b=bsD/8oanJqHe6j4j7wlKIWrw6sPskIZgpiT+OEX5rjD39T5nbjjVQ3UUabZ/xasm+b MWlEkiJpZO5+KIbG5GfosUYW7a3IlkMjaFFy6QeIugAzropn1JcY2Wd69kL0tU05u8ym /L8Xsjj4VPYBjmRAHtdOpWUaaY2+8xqRS6C1h+KWKIytMqt+q9ekxdy2KqdOEBY7PQqt /P7x4rafa1i7F8N/1Z9Ylw6JarG0CT+iuqCyVvE6KZkpLh/6xUZWVN09Lg5fnsKsxcSa B67E2P3JxYVCzwbnurSjBPZqHZbCSfplTkh4xQ0msQOTlvdiBkbnvvRY2kaMn+Tc9JJx fbVg== 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:arc-authentication-results; bh=NwA3Ie3PRJEI3Q7lhIj6Vt2WsgYRUtniPF3iz4HH0pc=; b=bjwzyYHZafxunG6xz0IFGExafHmze/dBSVl/NSq3fGRNPGW3QJ4ux0uhmS0koaRZE2 vPdxan9dkhSaxwxGjr6NtjQfXQsBCHLSjgvO2u2oId9hEDK+AEmKHnVwhyHbF14nKeX7 HOC1XY+fVqHV3efWMsU9V3GWpm5oNadjXXJ1Nd7KZvRfUUf48uorKT6mQBLEqPQ0Mgxn yh3A6Giw2+6xLVDhOGkU19vaLqhBwJk9bdvaIc0YyYzVDQvbpIaHLD1kiTjeocr9xXjd +jhQUHPPF5LAW2MmWM1wYSlL50FgoM908dET5ENKCrq5YvXFc6To1K02xQX/uqBj9nBY C7Gw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si9266909plc.173.2018.07.06.14.55.52; Fri, 06 Jul 2018 14:56:06 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754193AbeGFVyj (ORCPT + 99 others); Fri, 6 Jul 2018 17:54:39 -0400 Received: from mga05.intel.com ([192.55.52.43]:62473 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753631AbeGFVyi (ORCPT ); Fri, 6 Jul 2018 17:54:38 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jul 2018 14:54:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,318,1526367600"; d="scan'208";a="65001556" Received: from theros.lm.intel.com (HELO linux.intel.com) ([10.232.112.164]) by orsmga003.jf.intel.com with ESMTP; 06 Jul 2018 14:54:37 -0700 Date: Fri, 6 Jul 2018 15:54:37 -0600 From: Ross Zwisler To: Oscar Salvador Cc: Ross Zwisler , pasha.tatashin@oracle.com, linux-nvdimm@lists.01.org, bhe@redhat.com, Dave Hansen , LKML , Linux MM , Michal Hocko , Vlastimil Babka , Andrew Morton , "Kirill A. Shutemov" , osalvador@suse.de Subject: Re: [PATCH] mm/sparse.c: fix error path in sparse_add_one_section Message-ID: <20180706215437.GB21639@linux.intel.com> References: <20180706190658.6873-1-ross.zwisler@linux.intel.com> <20180706212327.GA10824@techadventures.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180706212327.GA10824@techadventures.net> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 06, 2018 at 11:23:27PM +0200, Oscar Salvador wrote: > On Fri, Jul 06, 2018 at 01:06:58PM -0600, Ross Zwisler wrote: > > The following commit in -next: > > > > commit 054620849110 ("mm/sparse.c: make sparse_init_one_section void and > > remove check") > > > > changed how the error handling in sparse_add_one_section() works. > > > > Previously sparse_index_init() could return -EEXIST, and the function would > > continue on happily. 'ret' would get unconditionally overwritten by the > > result from sparse_init_one_section() and the error code after the 'out:' > > label wouldn't be triggered. > > My bad, I missed that. > > > diff --git a/mm/sparse.c b/mm/sparse.c > > index 9574113fc745..d254bd2d3289 100644 > > --- a/mm/sparse.c > > +++ b/mm/sparse.c > > @@ -753,8 +753,12 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, > > * plus, it does a kmalloc > > */ > > ret = sparse_index_init(section_nr, pgdat->node_id); > > - if (ret < 0 && ret != -EEXIST) > > - return ret; > > + if (ret < 0) { > > + if (ret == -EEXIST) > > + ret = 0; > > + else > > + return ret; > > + } > > sparse_index_init() can return: > > -ENOMEM, -EEXIST or 0. > > So what about this?: > > diff --git a/mm/sparse.c b/mm/sparse.c > index f55e79fda03e..eb188eb6b82d 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -770,6 +770,7 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, > ret = sparse_index_init(section_nr, pgdat->node_id); > if (ret < 0 && ret != -EEXIST) > return ret; > + ret = 0; > > Does this look more clean? Sure, that's probably better. Andrew, what's the easiest way forward? I can send out a v2, you can fold this into his previous patch, or something else?