Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9613779ybl; Fri, 17 Jan 2020 15:24:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxJRXhEU/eS7Wr1lh4vup0yvmLJ5CZPj494yK45xZdBuudu8XPwR3UvQczrLqPaPFgBaHtC X-Received: by 2002:aca:cf58:: with SMTP id f85mr5330033oig.6.1579303461109; Fri, 17 Jan 2020 15:24:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579303461; cv=none; d=google.com; s=arc-20160816; b=zYwcCugP8T9N9zbWnCiSaF4k3882yXJm0CHXNl4P58pObkKBDK8Ux9/hVx8ZonWK9Q JSZfm9rdZ5Gl/0/naj4Ra37IEvr482WHIiYyRRYYwZf6bJiAgnmfsPD8nuCep5n1i82F xLZkKgxm5KHP5AZLkZ6373MUw+DNEc5Ifp9EZL1eH6xk53M9GrERH4hdNwt/f0wyUYtw k7fMLGUxeYS1VAr3DnamkOK2+CiBmZSRdhfkUS86/e4NWEuY6+hKW3snepNwCGtpMAxN FPhJnJdUFedRsjkYLvGezUK443xLW65H8fOm6oeuQhJVQwF+Z8jOje7jJThRdgQbhEYU wHkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Pea4XmD0J9oroRK5GOr0waz8UQFz86yNPKWz3Uvwlko=; b=fKIRbt591SG53VC1BpZ3q1qmmdgvvHcGdYUHcTgf/ULicRWfctzwn93Wp5F4uhMt+/ iC9wPEjO1fkrad4mnIzAlzk5WGEESAWpfvuPTjHFzqNCJxEG9daIarq/b6YKvYDgKx1G bHG8DsWq3Hw+iSM3EcYUkIsMX8PFo5CqTDF8+7M1QHEBX5m7zOnYnExJba19dKVVa1UB rbpkTf+h9zQCsphfCCRGjWdFenof+4bdk7WC3QvSHwXTq/ooxXO4hZt6f8ms5j7QyGK7 4HfKEYvcroa2FadNQTzLqh7vZlveKJgK9fRoN+LOC2B75zGs3Jas44sDTRrnGhcC0X3h RAYQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si15962942otr.102.2020.01.17.15.24.09; Fri, 17 Jan 2020 15:24:21 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730342AbgAQXXJ (ORCPT + 99 others); Fri, 17 Jan 2020 18:23:09 -0500 Received: from mga06.intel.com ([134.134.136.31]:9953 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729099AbgAQXXJ (ORCPT ); Fri, 17 Jan 2020 18:23:09 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2020 15:23:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,332,1574150400"; d="scan'208";a="306388172" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga001.jf.intel.com with ESMTP; 17 Jan 2020 15:23:07 -0800 From: Wei Yang To: akpm@linux-foundation.org, dan.j.williams@intel.com, aneesh.kumar@linux.ibm.com, kirill@shutemov.name, yang.shi@linux.alibaba.com, richardw.yang@linux.intel.com, thellstrom@vmware.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/5] mm/mremap: use pmd_addr_end to calculate next in move_page_tables() Date: Sat, 18 Jan 2020 07:22:52 +0800 Message-Id: <20200117232254.2792-4-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200117232254.2792-1-richardw.yang@linux.intel.com> References: <20200117232254.2792-1-richardw.yang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the general helper instead of do it by hand. Signed-off-by: Wei Yang --- mm/mremap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/mremap.c b/mm/mremap.c index c2af8ba4ba43..a258914f3ee1 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -253,11 +253,8 @@ unsigned long move_page_tables(struct vm_area_struct *vma, for (; old_addr < old_end; old_addr += extent, new_addr += extent) { cond_resched(); - next = (old_addr + PMD_SIZE) & PMD_MASK; - /* even if next overflowed, extent below will be ok */ + next = pmd_addr_end(old_addr, old_end); extent = next - old_addr; - if (extent > old_end - old_addr) - extent = old_end - old_addr; old_pmd = get_old_pmd(vma->vm_mm, old_addr); if (!old_pmd) continue; @@ -301,7 +298,7 @@ unsigned long move_page_tables(struct vm_area_struct *vma, if (pte_alloc(new_vma->vm_mm, new_pmd)) break; - next = (new_addr + PMD_SIZE) & PMD_MASK; + next = pmd_addr_end(new_addr, new_addr + len); if (extent > next - new_addr) extent = next - new_addr; move_ptes(vma, old_pmd, old_addr, old_addr + extent, new_vma, -- 2.17.1