Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp492605ybf; Fri, 28 Feb 2020 01:59:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyB//Gei8JcMBb6+9CS6aawXK91q5NyE7CRp0w93l8N1lV7wnfhikPDUGwxJKrBMwoCNA6S X-Received: by 2002:aca:2b0a:: with SMTP id i10mr2481853oik.137.1582883969323; Fri, 28 Feb 2020 01:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582883969; cv=none; d=google.com; s=arc-20160816; b=HnEsFQrEeVd0cjo8Q5ZqYatvXkF3RCKNZ/mUB82E3HdRAB10B5qzP4+YNhlYyNpO65 sj74l3Wu6GS5OA9ZccYnhgtL+bCUmdRLPqrSc6HYgbTQcB7wJVAZCatbx25qehSrf383 EVz5xMrc6rtozYHTKTQYXf7LDzeM7lxR0ev85ED5r1DgFE4PhiFPdINY8Ai+sHZiDS90 XMApO3OxnY+PYMw5oybfxCcdbTieojjlSxph2Uov2MJvv6ZmLwCBGfU7zww9I7t2vNEt /MhbvtMAcHv30mKzKAJfAgVAi11RS5AK1E5mC/FErKnHIz0E0jYsSMwrhFccbp7gjzxv mnww== 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:date:subject:cc:to:from :dkim-signature; bh=MNW9HVPqI0kTe9A0LBBiSsbv8ETEfJ83EjG1Wn7sou0=; b=k1q+J6KV6IDpL969Qi7HED9fYrgf+CbgQetRSyStyxDO7PqJLOU++mFnvVCYzKtIxI m7JAxnJXCVDkH147W5svLeqwT2+iMz44WX2Rlb/k2Gw65fOFx1kUjfD1CvgkzMtQh6vs swHJ4MRtlR6yf8TrDQ/XYCBNRuCVS7//U3kyNaQNUW2i9DxgvlqIrvT0LVtDhOaz1fvu m1T9gPJ6jTvTyE7ybWk5bxb+ZIm880RtxuVFi0DQEMdoFaFU2MVs5MWtmnR9fbQ39vjP ZR2w1n/Jmfl7oymd9y5ewZIXj+Yjt/anOtP9nPg+pkArthydMcM62cLLMNOYYLzxxkyi zU8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iNRAbSPO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 13si1581479oiy.28.2020.02.28.01.59.17; Fri, 28 Feb 2020 01:59:29 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=iNRAbSPO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727196AbgB1J6p (ORCPT + 99 others); Fri, 28 Feb 2020 04:58:45 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23215 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726413AbgB1J6k (ORCPT ); Fri, 28 Feb 2020 04:58:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582883919; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MNW9HVPqI0kTe9A0LBBiSsbv8ETEfJ83EjG1Wn7sou0=; b=iNRAbSPOKoFqjQ+a2eaF1sTRBljmdZcWWJxAspAcsBglM5THPde9GSg6xYSw5jAuI8QWGE vMtroG4plU4KIEIler/NN9gxBENdOXPopH4FfqkGrHg/PRS5hTxqo5TFuaF6VjZ60oIpma NbkBQZeIGoMpnPkenGEs6LBXi5+2UgI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-389-wBE7xIANOIGU3sQYTsMG0A-1; Fri, 28 Feb 2020 04:58:34 -0500 X-MC-Unique: wBE7xIANOIGU3sQYTsMG0A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFD30800D5B; Fri, 28 Feb 2020 09:58:32 +0000 (UTC) Received: from t480s.redhat.com (ovpn-117-180.ams2.redhat.com [10.36.117.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id A40C76E3EE; Fri, 28 Feb 2020 09:58:30 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Segher Boessenkool , Andrew Morton , Oscar Salvador , Michal Hocko , Baoquan He , Dan Williams , Wei Yang Subject: [PATCH v2 1/2] mm/memory_hotplug: simplify calculation of number of pages in __remove_pages() Date: Fri, 28 Feb 2020 10:58:18 +0100 Message-Id: <20200228095819.10750-2-david@redhat.com> In-Reply-To: <20200228095819.10750-1-david@redhat.com> References: <20200228095819.10750-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit 52fb87c81f11 ("mm/memory_hotplug: cleanup __remove_pages()"), we cleaned up __remove_pages(), and introduced a shorter variant to calculate the number of pages to the next section boundary. Turns out we can make this calculation easier to read. We always want to have the number of pages (> 0) to the next section boundary, starting fro= m the current pfn. We'll clean up __remove_pages() in a follow-up patch and directly make use of this computation. Suggested-by: Segher Boessenkool Cc: Andrew Morton Cc: Oscar Salvador Cc: Michal Hocko Cc: Baoquan He Cc: Dan Williams Cc: Wei Yang Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 4a9b3f6c6b37..8fe7e32dad48 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -534,7 +534,8 @@ void __remove_pages(unsigned long pfn, unsigned long = nr_pages, for (; pfn < end_pfn; pfn +=3D cur_nr_pages) { cond_resched(); /* Select all remaining pages up to the next section boundary */ - cur_nr_pages =3D min(end_pfn - pfn, -(pfn | PAGE_SECTION_MASK)); + cur_nr_pages =3D min(end_pfn - pfn, + SECTION_ALIGN_UP(pfn + 1) - pfn); __remove_section(pfn, cur_nr_pages, map_offset, altmap); map_offset =3D 0; } --=20 2.24.1