Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2182861ybi; Sun, 16 Jun 2019 23:51:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzI408W1uebu6NpMAQgN94lRD+RxtDCEgpUT/eQHSMb1oX/s4/ZlpsZx0ES9ly+jJWUebkL X-Received: by 2002:a17:90a:1b4a:: with SMTP id q68mr24615385pjq.61.1560754311983; Sun, 16 Jun 2019 23:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560754311; cv=none; d=google.com; s=arc-20160816; b=XuYsGuvyugOgLjazQlH+aIZCOEN7k37rnVD/68VeE3qgAXH5GYAQM1QJJvLXA4TpqB 5taDFfkmVBgvCp5I4n0BIGQbKoVP3JWiam9dpQ23hUVcPFf89qBoxV3JmvXhrsNzVi3B nf2x9d6NjjBM8h4wWchL2HEDe6P94jIKK/uTQHaGOtzsLSCSdXdXKAlIpomBhtGl8nQB 5IkNmNisZF7ivQuN1WuCZe1XqJ46PTijqy8qiQLFi0Gfewq5Yn2NHkrcqhNBbfdAhDKs 6DOQB/t9eSRuy9iW1W24c3Trx9GOSU0UGkoMleSTb6iC78Cu6FgfbJoAYhaUA/3DCfGe WLpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=cqvAr9VASkspbEuGbxxFTsdCiPDvlZPfVuw7byQIFRU=; b=cSR4dyADBN8xpQQxe98gegs3mj44QMNj5PaGPXMffv9Cm7RCvpXd1RpY56jlDrIDjN EsxalFVInneur3qykOxrwIULqHcIR9PW+P14rKC28r9bd1mzH4gTo0EbdP2b5gU1rcn1 VdJ2bYOZKArCT02dxIpuDRKaqVOUfXh5lVEFcl5ph6Zlbt95UOEuY84CObuszovofq3T uuu+R5DAJWgMQotWIGcz/IS952qOJ4cuXdXLIU6q7+CwjFBDO1aYLUu+NoeMsEvYhPgQ edoySTlSdyiVKPssmicV1n+fCv57gLtl7VGyAcM+P+C8/7rlB5iCnyjgY69qwmKyp7j2 yl/A== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21si9606605pgv.266.2019.06.16.23.51.35; Sun, 16 Jun 2019 23:51:51 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725983AbfFQGuK (ORCPT + 99 others); Mon, 17 Jun 2019 02:50:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35004 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725778AbfFQGuK (ORCPT ); Mon, 17 Jun 2019 02:50:10 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5H6mbO0052918 for ; Mon, 17 Jun 2019 02:50:09 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2t63bhd1kn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Jun 2019 02:50:08 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Jun 2019 07:50:06 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 17 Jun 2019 07:50:01 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5H6o0He49807480 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 06:50:00 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5514611C04C; Mon, 17 Jun 2019 06:50:00 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB73F11C05E; Mon, 17 Jun 2019 06:49:58 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.53]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 17 Jun 2019 06:49:58 +0000 (GMT) Date: Mon, 17 Jun 2019 09:49:57 +0300 From: Mike Rapoport To: "Alastair D'Silva" Cc: alastair@d-silva.org, Andrew Morton , Oscar Salvador , David Hildenbrand , Michal Hocko , Pavel Tatashin , Wei Yang , Juergen Gross , Qian Cai , Thomas Gleixner , Ingo Molnar , Josh Poimboeuf , Konrad Rzeszutek Wilk , Jiri Kosina , Peter Zijlstra , Mukesh Ojha , Arun KS , Mike Rapoport , Baoquan He , Logan Gunthorpe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/5] mm: don't hide potentially null memmap pointer in sparse_remove_one_section References: <20190617043635.13201-1-alastair@au1.ibm.com> <20190617043635.13201-3-alastair@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190617043635.13201-3-alastair@au1.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19061706-0016-0000-0000-00000289B0E9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19061706-0017-0000-0000-000032E6F883 Message-Id: <20190617064956.GB16810@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-17_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=909 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170063 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 17, 2019 at 02:36:28PM +1000, Alastair D'Silva wrote: > From: Alastair D'Silva > > By adding offset to memmap before passing it in to clear_hwpoisoned_pages, > is hides 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. > > Signed-off-by: Alastair D'Silva One nit below, otherwise Reviewed-by: Mike Rapoport > --- > mm/sparse.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/mm/sparse.c b/mm/sparse.c > index 104a79fedd00..66a99da9b11b 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -746,12 +746,14 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn, > kfree(usemap); > __kfree_section_memmap(memmap, altmap); > } > + The whitespace change here is not related > return ret; > } > > #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 map_offset, int nr_pages) > { > int i; > > @@ -767,7 +769,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 = map_offset; i < nr_pages; i++) { > if (PageHWPoison(&memmap[i])) { > atomic_long_sub(1, &num_poisoned_pages); > ClearPageHWPoison(&memmap[i]); > @@ -775,7 +777,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 map_offset, int nr_pages) > { > } > #endif > @@ -822,8 +825,7 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, > ms->pageblock_flags = NULL; > } > > - clear_hwpoisoned_pages(memmap + map_offset, > - PAGES_PER_SECTION - map_offset); > + clear_hwpoisoned_pages(memmap, map_offset, PAGES_PER_SECTION); > free_section_usemap(memmap, usemap, altmap); > } > #endif /* CONFIG_MEMORY_HOTREMOVE */ > -- > 2.21.0 > -- Sincerely yours, Mike.