Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5172505ybl; Tue, 27 Aug 2019 00:08:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqye94bjgZ4sUFLuDIMe+6b0juq4qmQ7wn2hTEy7KWdj1MFWjVaKGJ2x4+9tEdUsTihewYD6 X-Received: by 2002:a62:e516:: with SMTP id n22mr24785029pff.105.1566889697303; Tue, 27 Aug 2019 00:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566889697; cv=none; d=google.com; s=arc-20160816; b=ZV3+xZIiYnDXhqsWyRumkt4BHPZR/w7CA31BlJKvG7LiwOa4g1i8/dAMZh5gKLs/YE +S88n2KK4cjQTB7DtOoImSKF6XJBc3KEb+z3OGMG65W78VWeJfu0d5Y1P8YwrMsaR4pp aXOtok8tLeGp+9jaafqokif///riOwfVN9uyYyA8vKol7dIxZBGQZSbjGeILMYW84mcd 4rEyle0QgauLTWFVUGl5jqTLqFQ6i1a0pNZJhoF/peG50azMnmyMXQspuJQSVe2PU4ZP RDUIkE0oLzWk1VrxV20LBzWyzdveYYGdQl/SuMWsgDNBWZAznDAXEPs3+OTR46zZJgEg DyKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=sx8T/JaChqJsv4gBQ0jIUGE63s8HP98STm886EZef2g=; b=XokDfUCHjDaDacTyCMfEo9bXRfbrZfkp+tRnmb0qrxXfQuxyvAOnYSkjWI6ix6FANp hZHgdNB+FLnHK1SrRhJZhlrO7kvpRc5R+jL1vEQE9nNEQ1iURrdxL4zUSvchUYrC/flc 0z0o6XRubCzk8iaHNHh0MiYABPpzR61Zkmuy4FFcLn85Y+np8a8zUKXfqdI0SFsJSnoc Iknct9//2fhP+u5DL/PTPaOf3zXOzBELalqWK4uNJkegKLB1CsBdD2Um60yCbaQtx+TN bt/ze96/mXzdl44vuJqv+QK8Cim98UFaVo3BHI0diRMZwoP25+aw60rX+B/IZFEpnV5N 8VwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@d-silva.org header.s=201810a header.b="C6v/ytGk"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gb16si12212225plb.389.2019.08.27.00.08.02; Tue, 27 Aug 2019 00:08:17 -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=@d-silva.org header.s=201810a header.b="C6v/ytGk"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727718AbfH0HHI (ORCPT + 99 others); Tue, 27 Aug 2019 03:07:08 -0400 Received: from ushosting.nmnhosting.com ([66.55.73.32]:52164 "EHLO ushosting.nmnhosting.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbfH0HHF (ORCPT ); Tue, 27 Aug 2019 03:07:05 -0400 X-Greylist: delayed 386 seconds by postgrey-1.27 at vger.kernel.org; Tue, 27 Aug 2019 03:07:05 EDT Received: from mail2.nmnhosting.com (unknown [202.169.106.97]) by ushosting.nmnhosting.com (Postfix) with ESMTPS id 6A0512DC009A; Tue, 27 Aug 2019 03:00:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=d-silva.org; s=201810a; t=1566889239; bh=Vicp1z3ZYemzE7DrudrWvYVfOYkLSvM90bJCLdQ9aRM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=C6v/ytGkutpfzP2PTxrtBrSOrb4+ce4MDkJwsciLjzlMDvtbaD/YozBZV3Ls5WRlm k08QBl8jwO4ZVA111hlNhazgFVw4HijplQz7qWREPrDb1rQ3PDUb9i/gXYhDj1QeVM rN16RfSPqXnOBdJvg1i9h9qfdcloSjoZF2NMOxHT1n0ZOcv4bpR/tyvEtsQ2bxVckr RQvG+Cqxj4+anhZF1w8iwbcwwavco6NFXdU+hm+IUOAp77E5ZH7hE5LzCPtCM2m6IB Sgv2zBatFyEC/qW2V5KiQF7RJsc62tKQ5LOU4H/xtDxmayaJnLRT7A1VxHxiLGMQSQ hNV8TSivv9k1DqfcYW74bmU1RRCzn2IjDqpr6ubsulqhzDO5V5nIS4fSR2kzy/bgb+ O5myAjyfXbIHwFi86sQ7Du8681wYwNrg733juzW6Hcbv9jGDmYnN29RMESUp6X0Rmf omA9W+2KN5ugfRg0oIWIW1wtbLv0IEtPDqW8hHk3Qg7bQ6HdsN4v1VhN3QHDpZvUcI FSWalw652x+LxZyGBii2JfqAwuFV3Pvlww5uPY9kJSxmCSHsWhAzHiJ1Nk5TyN0Pl7 7ddDF28KQ9LCAgVLWGDal0AeMOUhj7x/pMquym3PkJzU4/KXWYabbILsqVb7CGrBcW XjsmcwPtFOvIwHFlP+tCbv14= Received: from adsilva.ozlabs.ibm.com (static-82-10.transact.net.au [122.99.82.10] (may be forged)) (authenticated bits=0) by mail2.nmnhosting.com (8.15.2/8.15.2) with ESMTPSA id x7R70GV1043884 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Tue, 27 Aug 2019 17:00:32 +1000 (AEST) (envelope-from alastair@d-silva.org) Message-ID: Subject: Re: [PATCH 2/2] mm: don't hide potentially null memmap pointer in sparse_remove_section From: "Alastair D'Silva" To: Michal Hocko Cc: Andrew Morton , Oscar Salvador , Mike Rapoport , Dan Williams , Wei Yang , David Hildenbrand , Qian Cai , linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 27 Aug 2019 17:00:16 +1000 In-Reply-To: <20190827062445.GO7538@dhcp22.suse.cz> References: <20190827053656.32191-1-alastair@au1.ibm.com> <20190827053656.32191-3-alastair@au1.ibm.com> <20190827062445.GO7538@dhcp22.suse.cz> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.2 (3.32.2-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (mail2.nmnhosting.com [10.0.1.20]); Tue, 27 Aug 2019 17:00:34 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-08-27 at 08:24 +0200, Michal Hocko wrote: > On Tue 27-08-19 15:36:55, Alastair D'Silva wrote: > > From: Alastair D'Silva > > > > By adding offset to memmap before passing it in to > > clear_hwpoisoned_pages, > > we hide a theoretically null memmap from the null check inside > > clear_hwpoisoned_pages. > > Isn't that other way around? Calculating the offset struct page > pointer > will actually make the null check effective. Besides that I cannot > really see how pfn_to_page would return NULL. I have to confess that > I > cannot really see how offset could lead to a NULL struct page either > and > I strongly suspect that the NULL check is not really needed. Maybe it > used to be in the past. > You're probably right, but I didn't feel confident in removing the NULL check. While the NULL check remains though, I can't see how adding the offset would turn a non-NULL pointer into a NULL unless the pointer is invalid in the first place, and if this is the case, we should have a comment explaining this. The NULL check was added in commit: 95a4774d055c ("memory-hotplug: update mce_bad_pages when removing the memory") where memmap was originally inited to NULL, and only conditionally given a value. With this in mind, since that situation is no longer true, I think we could instead drop the NULL check. -- Alastair D'Silva mob: 0423 762 819 skype: alastair_dsilva Twitter: @EvilDeece blog: http://alastair.d-silva.org