Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp382506ybd; Tue, 25 Jun 2019 23:25:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqysHpBT5txajuFNllN1FAF5Uts/xEg1wVVzEnHoNJAVxzmLlamKO7w9tQKtrw+NkZAHhDI0 X-Received: by 2002:a17:902:d887:: with SMTP id b7mr3423056plz.28.1561530348691; Tue, 25 Jun 2019 23:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561530348; cv=none; d=google.com; s=arc-20160816; b=r8EOraFLzWRUpQMFHZWXXaECOiFzqc1EU51PC/LyeVManU7bitIzAJZcYnY+kLE9+f KAg43QVpDzaKWIHJi05TcF2MKmbLT0dDzU4Oko8qBTj9/3FduiqiLf3ZmoIdkkKE1LTs GhFwwxyWRIKW0Cl4RPKg96/0IfB5aG43vXyXKNEc71DgrFzuVA27v51PGQ9579SZa9ow oNBcD6RWOhn60BMHB6DYw7UTKUzO2nzxjF9QZzvvbczxC2Vr8btbWchVmCKNWInID/zW uGOPhsULbFFY5pRWqdBGsh4APqV3bFcCGclprvGDAYGLLRL1cINSy2XnYo/RePDZLjrB 22ow== 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; bh=SCQaZzbSxKSrAH0VgiQraIY2A91MTXFvXV8mrRzOWtY=; b=NQ8FYsJtjxewDkAXZk6l+IVx0ZmcFTJARmVvNFHeU5mqhJKbUYNgKTDy/T6b/wXwns dY6sdboBa8ySJvKHyVzaYsdMTOy+NOLJB0YXikogBwuhsEiB/fRsU+6C3aL1nkAsUq+j ZFXOeOPjhcbLxVWS4RY3+saX1c8UtgMThmpom4hFAC/155Q5ox3mSSIrZEfy2GenTU2D YrSfP6OJ0A3j/APcyixLCLiFNXrIBCc/LhFV0vGolzJhCsNoCO/Wu9o7kjCqhts/S1wX YaEv7J8S9/aB/tQS9cahHHjLjPu77CIKagbL0fE5mq4s1Mut1KUgNRazRMofuWOx9TQp rZug== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d126si15058128pgc.46.2019.06.25.23.25.20; Tue, 25 Jun 2019 23:25:48 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbfFZGXq (ORCPT + 99 others); Wed, 26 Jun 2019 02:23:46 -0400 Received: from mx2.suse.de ([195.135.220.15]:59306 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725379AbfFZGXq (ORCPT ); Wed, 26 Jun 2019 02:23:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0BAE6AD47; Wed, 26 Jun 2019 06:23:45 +0000 (UTC) Date: Wed, 26 Jun 2019 08:23:44 +0200 From: Michal Hocko To: Alastair D'Silva Cc: alastair@d-silva.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Pavel Tatashin , Oscar Salvador , Mike Rapoport , Baoquan He , Qian Cai , Logan Gunthorpe , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 2/3] mm: don't hide potentially null memmap pointer in sparse_remove_one_section Message-ID: <20190626062344.GG17798@dhcp22.suse.cz> References: <20190626061124.16013-1-alastair@au1.ibm.com> <20190626061124.16013-3-alastair@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190626061124.16013-3-alastair@au1.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 26-06-19 16:11:22, Alastair D'Silva wrote: > From: Alastair D'Silva > > By adding offset to memmap before passing it in to clear_hwpoisoned_pages, > we hide a potentially null memmap from the null check inside > clear_hwpoisoned_pages. > > This patch passes the offset to clear_hwpoisoned_pages instead, allowing > memmap to successfully peform it's null check. Same issue with the changelog as the previous patch (missing WHY). > > Signed-off-by: Alastair D'Silva > --- > mm/sparse.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/mm/sparse.c b/mm/sparse.c > index 57a1a3d9c1cf..1ec32aef5590 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -753,7 +753,8 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, > > #ifdef CONFIG_MEMORY_HOTREMOVE > #ifdef CONFIG_MEMORY_FAILURE > -static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages) > +static void clear_hwpoisoned_pages(struct page *memmap, > + unsigned long start, unsigned long count) > { > int i; > > @@ -769,7 +770,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages) > if (atomic_long_read(&num_poisoned_pages) == 0) > return; > > - for (i = 0; i < nr_pages; i++) { > + for (i = start; i < start + count; i++) { > if (PageHWPoison(&memmap[i])) { > atomic_long_sub(1, &num_poisoned_pages); > ClearPageHWPoison(&memmap[i]); > @@ -777,7 +778,8 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages) > } > } > #else > -static inline void clear_hwpoisoned_pages(struct page *memmap, int nr_pages) > +static inline void clear_hwpoisoned_pages(struct page *memmap, > + unsigned long start, unsigned long count) > { > } > #endif > @@ -824,7 +826,7 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, > ms->pageblock_flags = NULL; > } > > - clear_hwpoisoned_pages(memmap + map_offset, > + clear_hwpoisoned_pages(memmap, map_offset, > PAGES_PER_SECTION - map_offset); > free_section_usemap(memmap, usemap, altmap); > } > -- > 2.21.0 -- Michal Hocko SUSE Labs