Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A24DDC2D0DB for ; Mon, 20 Jan 2020 17:17:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6C5B7217F4 for ; Mon, 20 Jan 2020 17:17:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C5B7217F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 099EF6B0698; Mon, 20 Jan 2020 12:17:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 04BF06B0699; Mon, 20 Jan 2020 12:17:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA37C6B069A; Mon, 20 Jan 2020 12:17:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id D5D6F6B0698 for ; Mon, 20 Jan 2020 12:17:03 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id A057E181AC9CC for ; Mon, 20 Jan 2020 17:17:03 +0000 (UTC) X-FDA: 76398667926.15.cause36_5aae150feca1d X-HE-Tag: cause36_5aae150feca1d X-Filterd-Recvd-Size: 5539 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Mon, 20 Jan 2020 17:17:03 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id q10so223641wrm.11 for ; Mon, 20 Jan 2020 09:17:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kEYMCzpg5Y3ZBlBbc0R3YsIwbWtq+NyZ2Gxt9ht/DWE=; b=oPpISpDMDmtvGveJCLLLrVcIOHj8LlTg0Z1VvCudXR0lRsYaUy3u8eIkh5/SWYssr3 DcTi1gK+Zo0QD+Ue6llQULVLCOyKNvz2fLPfRwQjLabmlY6FL4ZAKKrHRkp8mrYSTRjG z/lJj8Ra0LaZvL6BAlPcGGSQjjYCgDYdlLra9D8GhWO2f9mLRmZ+xOqmWuT9tcODaPyS 5g+aBgzUSfZPaLa80lBV+HxApHrDbEiEPmX1+EWiJeO4a1mhkDXJFWJ1X6ZgQILYnO+O Tvz/qFJOrtJLFt81RrBbciOLrQcrXa2xguRsT26eL8OT7HniKgAAFdBl3aGY+Av5mLP2 bfAw== X-Gm-Message-State: APjAAAUbHAyMYhsRBrMBgp3Tdh0ydIXn/z2K363ald9n2uUAvnQPGwl/ BOgUBe7GgX734NTANDVaLh8= X-Google-Smtp-Source: APXvYqxmH0H4n5gECO7t2dqiUpCbt0SDkU6q+JbFc7hG6xUJ4gtX8mvxed1FR6xIwxuWjbLcyRRdsw== X-Received: by 2002:adf:b64b:: with SMTP id i11mr589441wre.58.1579540621745; Mon, 20 Jan 2020 09:17:01 -0800 (PST) Received: from localhost (ip-37-188-230-253.eurotel.cz. [37.188.230.253]) by smtp.gmail.com with ESMTPSA id v8sm46557560wrw.2.2020.01.20.09.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 09:17:01 -0800 (PST) Date: Mon, 20 Jan 2020 18:16:59 +0100 From: Michal Hocko To: Qian Cai Cc: akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -mm v3] mm/page_isolation: fix potential warning from user Message-ID: <20200120171659.GA29276@dhcp22.suse.cz> References: <20200120163915.1469-1-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200120163915.1469-1-cai@lca.pw> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon 20-01-20 11:39:15, Qian Cai wrote: > It makes sense to call the WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE) > from start_isolate_page_range(), but should avoid triggering it from > userspace, i.e, from is_mem_section_removable() because it could crash > the system by a non-root user if warn_on_panic is set. > > While at it, simplify the code a bit by removing an unnecessary jump > label. > > Suggested-by: Michal Hocko > Signed-off-by: Qian Cai Acked-by: Michal Hocko Thanks! > --- > > v3: Drop the page_isolation.c cleanup change. > v2: Improve the commit log. > Warn for all start_isolate_page_range() users not just offlining. > > mm/page_alloc.c | 11 ++++------- > mm/page_isolation.c | 18 +++++++++++------- > 2 files changed, 15 insertions(+), 14 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 621716a25639..3c4eb750a199 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -8231,7 +8231,7 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page, > if (is_migrate_cma(migratetype)) > return NULL; > > - goto unmovable; > + return page; > } > > for (; iter < pageblock_nr_pages; iter++) { > @@ -8241,7 +8241,7 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page, > page = pfn_to_page(pfn + iter); > > if (PageReserved(page)) > - goto unmovable; > + return page; > > /* > * If the zone is movable and we have ruled out all reserved > @@ -8261,7 +8261,7 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page, > unsigned int skip_pages; > > if (!hugepage_migration_supported(page_hstate(head))) > - goto unmovable; > + return page; > > skip_pages = compound_nr(head) - (page - head); > iter += skip_pages - 1; > @@ -8303,12 +8303,9 @@ struct page *has_unmovable_pages(struct zone *zone, struct page *page, > * is set to both of a memory hole page and a _used_ kernel > * page at boot. > */ > - goto unmovable; > + return page; > } > return NULL; > -unmovable: > - WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE); > - return pfn_to_page(pfn + iter); > } > > #ifdef CONFIG_CONTIG_ALLOC > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index e70586523ca3..a9fd7c740c23 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -54,14 +54,18 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_ > > out: > spin_unlock_irqrestore(&zone->lock, flags); > - if (!ret) > + if (!ret) { > drain_all_pages(zone); > - else if ((isol_flags & REPORT_FAILURE) && unmovable) > - /* > - * printk() with zone->lock held will guarantee to trigger a > - * lockdep splat, so defer it here. > - */ > - dump_page(unmovable, "unmovable page"); > + } else { > + WARN_ON_ONCE(zone_idx(zone) == ZONE_MOVABLE); > + > + if ((isol_flags & REPORT_FAILURE) && unmovable) > + /* > + * printk() with zone->lock held will likely trigger a > + * lockdep splat, so defer it here. > + */ > + dump_page(unmovable, "unmovable page"); > + } > > return ret; > } > -- > 2.21.0 (Apple Git-122.2) -- Michal Hocko SUSE Labs