From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=unavailable 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 B2A60C2BC11 for ; Wed, 9 Sep 2020 02:28:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4BA6E20936 for ; Wed, 9 Sep 2020 02:28:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BA6E20936 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 771B76B006E; Tue, 8 Sep 2020 22:28:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 720A06B0071; Tue, 8 Sep 2020 22:28:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 636756B0072; Tue, 8 Sep 2020 22:28:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id 4A0276B006E for ; Tue, 8 Sep 2020 22:28:13 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1010C1EE6 for ; Wed, 9 Sep 2020 02:28:13 +0000 (UTC) X-FDA: 77241938466.14.face40_5311476270d9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id DE68818229818 for ; Wed, 9 Sep 2020 02:28:12 +0000 (UTC) X-HE-Tag: face40_5311476270d9 X-Filterd-Recvd-Size: 4740 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Sep 2020 02:28:11 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0U8MaSxt_1599618487; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U8MaSxt_1599618487) by smtp.aliyun-inc.com(127.0.0.1); Wed, 09 Sep 2020 10:28:07 +0800 Date: Wed, 9 Sep 2020 10:28:07 +0800 From: Wei Yang To: Vlastimil Babka Cc: Wei Yang , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/mmap: leave adjust_next as virtual address instead of page frame number Message-ID: <20200909022807.GB14584@L-31X9LVDL-1304.local> Reply-To: Wei Yang References: <20200828081031.11306-1-richard.weiyang@linux.alibaba.com> <85daf46b-0d85-588a-2d6f-883afa6076dc@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <85daf46b-0d85-588a-2d6f-883afa6076dc@suse.cz> X-Rspamd-Queue-Id: DE68818229818 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.004318, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Sep 08, 2020 at 05:31:22PM +0200, Vlastimil Babka wrote: >On 8/28/20 10:10 AM, Wei Yang wrote: >> Instead of convert adjust_next between virtual address and page frame >> number, let's just store the virtual address into adjust_next. > >IMHO more precisely/less confusing it's "bytes" and "pages" instead of "virtual >address" (which is absolute address, but this variable holds a difference) and >"page frame number" (which is related to absolute physical address, but what we >have is difference in pages in virtual address space). > Thanks for your comment. To be honest, I am not sure which one is more precise. English is not my mother tongue. If others think this is better, I am fine to adjust this. >> Also, this patch fixes one typo in the comment of >> vma_adjust_trans_huge(). >> >> Signed-off-by: Wei Yang > >Other than that, seems like it leads to less shifting, so >Acked-by: Vlastimil Babka > >> --- >> mm/huge_memory.c | 4 ++-- >> mm/mmap.c | 8 ++++---- >> 2 files changed, 6 insertions(+), 6 deletions(-) >> >> diff --git a/mm/huge_memory.c b/mm/huge_memory.c >> index 78c84bee7e29..2c633ba14440 100644 >> --- a/mm/huge_memory.c >> +++ b/mm/huge_memory.c >> @@ -2300,13 +2300,13 @@ void vma_adjust_trans_huge(struct vm_area_struct *vma, >> >> /* >> * If we're also updating the vma->vm_next->vm_start, if the new >> - * vm_next->vm_start isn't page aligned and it could previously >> + * vm_next->vm_start isn't hpage aligned and it could previously >> * contain an hugepage: check if we need to split an huge pmd. >> */ >> if (adjust_next > 0) { >> struct vm_area_struct *next = vma->vm_next; >> unsigned long nstart = next->vm_start; >> - nstart += adjust_next << PAGE_SHIFT; >> + nstart += adjust_next; >> if (nstart & ~HPAGE_PMD_MASK && >> (nstart & HPAGE_PMD_MASK) >= next->vm_start && >> (nstart & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE <= next->vm_end) >> diff --git a/mm/mmap.c b/mm/mmap.c >> index 90b1298d4222..e4c9bbfd4103 100644 >> --- a/mm/mmap.c >> +++ b/mm/mmap.c >> @@ -758,7 +758,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, >> * vma expands, overlapping part of the next: >> * mprotect case 5 shifting the boundary up. >> */ >> - adjust_next = (end - next->vm_start) >> PAGE_SHIFT; >> + adjust_next = (end - next->vm_start); >> exporter = next; >> importer = vma; >> VM_WARN_ON(expand != importer); >> @@ -768,7 +768,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, >> * split_vma inserting another: so it must be >> * mprotect case 4 shifting the boundary down. >> */ >> - adjust_next = -((vma->vm_end - end) >> PAGE_SHIFT); >> + adjust_next = -(vma->vm_end - end); >> exporter = vma; >> importer = next; >> VM_WARN_ON(expand != importer); >> @@ -840,8 +840,8 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, >> } >> vma->vm_pgoff = pgoff; >> if (adjust_next) { >> - next->vm_start += adjust_next << PAGE_SHIFT; >> - next->vm_pgoff += adjust_next; >> + next->vm_start += adjust_next; >> + next->vm_pgoff += adjust_next >> PAGE_SHIFT; >> } >> >> if (root) { >> -- Wei Yang Help you, Help me