Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1360904ybl; Wed, 14 Aug 2019 15:41:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwscb5wZxCpsjpV0e9+35rICN0X+agCUsQEk2yHpE0OvnFN91AWumSJEtmrz/iKz/RwELUj X-Received: by 2002:a65:60d3:: with SMTP id r19mr1175761pgv.91.1565822500061; Wed, 14 Aug 2019 15:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565822500; cv=none; d=google.com; s=arc-20160816; b=C7WH0kpSVt1l9YsdPFur7YillcTsU3SgDFvxdLhHl8Sdx7qgGy1pHkooYbCpaMt15b gROEX+sUgxcbVMiOuuIPdQ/CH9EkUltyd0/nAIPliX7aZMQGyL4AZLvA3kcd5fS9ME2y VSHfMNPICgfZpg1fNJ9qgk4TmCvGH4UVq/MNYRJT9W55rxKv7zEUtJHzZfseDrYXgyTk X6pT/XVG53XcXANM6qZ4ETQsEwWkDMLrPEtpy6QkZo+wgJz1UV5T/M33s8YXgEstPmHR 2H8lOJJTtKLJ/IRLT63xNes3A1V8jnSnwowZcLt9i3nYQu4Al5ETmOzJMm9N5sfkvHtT 32tA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=BYlM/yx5eoD4J0MFmg1MHPDyWVXTJGiO6OM6tvBQJcs=; b=lpjyIIihzbemo/SkVjmgtVF4gCha9FDpxMDtpVQ7owxf5rOBaJaMZi+NUkOR01+TMK RSdtLVJ3EEgt14nxfNJJza93l4IRtwmriBas6MZxjAPY/NfY2ZazoLHpR53XO5vv0uTV qAcGFvkPcSN0AuN1xZWjL68i/kYbEu/gm5Q1GEq5aDxwzb+mjC4jLLfkVM1/BuMVleCC R2t8woVJztG4QVpiIT7POZfkH6ODgHUBPb1ZQgc2di6/f0LkHFavV2on95Kuue7VFcf3 fhmuWAVvhI8qXC+b8XE4aQXkwZ5sjq5b1QqfPsj64+DqHyg1tKWu6dPl7uBilbXepHDk 9xjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pi6KnQed; 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 1si710162plv.44.2019.08.14.15.41.23; Wed, 14 Aug 2019 15:41:40 -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=@kernel.org header.s=default header.b=pi6KnQed; 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 S1729998AbfHNU4K (ORCPT + 99 others); Wed, 14 Aug 2019 16:56:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728443AbfHNU4J (ORCPT ); Wed, 14 Aug 2019 16:56:09 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CFD9E20651; Wed, 14 Aug 2019 20:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565816169; bh=/47vrJUcPnKmlW6QGCuX38MeKmclx+u9kcMLBRaqbs4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pi6KnQedP5wNrNC9WqJkX3iCMipQiegirC5UJ923ryfPZa6rrSPNcrL5FvjWNzJXe uEFWtt5gQsv862Iv7+Ak1EKlQ+6njDmiCuKvxWLGmoM9pJ6Yd4U9QopjJbdgxB9+VC biiBIGKf53FEg32rV49NF8iWU1PTqPGbKbe77Sa0= Date: Wed, 14 Aug 2019 13:56:08 -0700 From: Andrew Morton To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Arun KS , Oscar Salvador , Michal Hocko , Pavel Tatashin , Dan Williams Subject: Re: [PATCH v2 4/5] mm/memory_hotplug: Make sure the pfn is aligned to the order when onlining Message-Id: <20190814135608.a449ca5a75cd700e077a8d23@linux-foundation.org> In-Reply-To: <20190814154109.3448-5-david@redhat.com> References: <20190814154109.3448-1-david@redhat.com> <20190814154109.3448-5-david@redhat.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Aug 2019 17:41:08 +0200 David Hildenbrand wrote: > Commit a9cd410a3d29 ("mm/page_alloc.c: memory hotplug: free pages as higher > order") assumed that any PFN we get via memory resources is aligned to > to MAX_ORDER - 1, I am not convinced that is always true. Let's play safe, > check the alignment and fallback to single pages. > > ... > > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -646,6 +646,9 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages, > */ > for (pfn = start_pfn; pfn < end_pfn; pfn += 1ul << order) { > order = min(MAX_ORDER - 1, get_order(PFN_PHYS(end_pfn - pfn))); > + /* __free_pages_core() wants pfns to be aligned to the order */ > + if (unlikely(!IS_ALIGNED(pfn, 1ul << order))) > + order = 0; > (*online_page_callback)(pfn_to_page(pfn), order); > } We aren't sure if this occurs, but if it does, we silently handle it. It seems a reasonable defensive thing to do, but should we add a WARN_ON_ONCE() so that we get to find out about it? If we get such a report then we can remove the WARN_ON_ONCE() and add an illuminating comment.