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=-2.1 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 6492DC433E0 for ; Tue, 5 Jan 2021 02:38:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E277B22573 for ; Tue, 5 Jan 2021 02:38:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E277B22573 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 183C36B00FD; Mon, 4 Jan 2021 21:38:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10EAB6B00FE; Mon, 4 Jan 2021 21:38:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F17B38D0036; Mon, 4 Jan 2021 21:38:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id D89FD6B00FD for ; Mon, 4 Jan 2021 21:38:34 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 936D81EE6 for ; Tue, 5 Jan 2021 02:38:34 +0000 (UTC) X-FDA: 77670162948.14.tiger39_5202ddb274d5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 6A67F18229818 for ; Tue, 5 Jan 2021 02:38:34 +0000 (UTC) X-HE-Tag: tiger39_5202ddb274d5 X-Filterd-Recvd-Size: 5706 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 02:38:33 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id o13so69287133lfr.3 for ; Mon, 04 Jan 2021 18:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=2SbjfiHu12LMwP8hZzXoi4ay41vV/4ruDWvlCAJyjU8=; b=MjlK2Bc4MoOgUX0hkL+Dkz/nLJSeL7i0gZyMQsoQ0y9zL2BexKGxhnYda7sE+zbCJL +s1xVtHtLDfPneDnZogSSISZe1+VWvqQSoKkT4YL3oP4Az2EKbGhOaEwtTYdfdKH5vbV 5RmXaR48LWuT3nG67MyHqlPQ0e1lNNC29rBmlfTMXV92ogKNv1xJL/6zFl4XR6JQeLEp BLpquBXm6gpejRxAgr31tE8rWwnp5Qu055OjojGYCPyRt2LPMje7aOi1TnI3vQ5MzJHA /pV1r0/E6CketZ5nhcY+LPBwd7dpZbhY6TlVtS54yf0ijyZzloOxLsqfF5cnbxwlGbQy fsfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2SbjfiHu12LMwP8hZzXoi4ay41vV/4ruDWvlCAJyjU8=; b=a2/qPbglprnLXeCokwiDKOeLvxp7NT67g+Z8RLnLEQjBcoHJTzKuM67tJBKoDT0SFP mTYS1MFRy1YUZ6k8SsrtJszqEk3YXGwiGQsSW07ANiAaFdqcQZaEUTkcKAK6szc+p7GN K1OwdTSzDrPH2LwHD0POPbfH3FXQRzsEVapWgWVvaoxH66Uhf1g+h6PtQ8cBXvm5kYw9 +dYrtTM09rBnQJyCDM6kt+5x9L6XlAkwIGeKFQnbn4JiCs3n1iUT8GT57kBh1umt0h5w IpfpQIGqACg5D3jRGHy5a54F5Nl/FeG/T+k3IHok74lCLujk+QYsRkpYR7YsYaYho8wV CXjw== X-Gm-Message-State: AOAM531FHsFTCevnVso9mVxitGGF1A1LkZ9K5m2vR6/5hMWXifuREct2 VotEf4+YTfacNQerL99Oeak= X-Google-Smtp-Source: ABdhPJwVm++geBZ3V/6Xo04dA5J92ee5JXahhSMzjs7U8MNlRmhPQnUOjfOdZrUvT9To/neP88ShRw== X-Received: by 2002:a19:8c05:: with SMTP id o5mr14584217lfd.304.1609814312508; Mon, 04 Jan 2021 18:38:32 -0800 (PST) Received: from localhost.localdomain ([2a03:5342:f:6::3]) by smtp.gmail.com with ESMTPSA id y12sm7591277lfy.300.2021.01.04.18.38.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Jan 2021 18:38:31 -0800 (PST) Subject: Re: [PATCH] mm/hugetlb.c: fix unnecessary address expansion of pmd sharing From: Li Xinhai To: Mike Kravetz , linux-mm@kvack.org Cc: akpm@linux-foundation.org, Peter Xu References: <20201229042125.2663029-1-lixinhai.lxh@gmail.com> <2b6534f5-2ffa-6325-6af1-8c067ba9c0bc@oracle.com> <2d8a7726-b7fb-3dc8-e7bc-54a67d28db24@oracle.com> <2a95c320-4408-2603-f266-8e111a2f1620@gmail.com> <049fb8f0-73c8-b296-7670-7b60fdcc092a@oracle.com> <1617a471-b837-a868-67a0-0b0f17cb3748@gmail.com> <6aaf1556-33e1-c9cd-5f41-11cd96c014f4@oracle.com> Message-ID: <76585d60-f4d7-646e-6e45-2d68368561c4@gmail.com> Date: Tue, 5 Jan 2021 10:38:22 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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 1/5/21 10:10 AM, Li Xinhai wrote: >=20 >=20 > On 1/5/21 2:59 AM, Mike Kravetz wrote: >> On 1/3/21 11:10 PM, Li Xinhai wrote: >>> >>> >>> On 1/4/21 11:55 AM, Mike Kravetz wrote: >>>> I believe the only case where your patch produced incorrect results = is >>>> when the range was within a vma that was smaller than PUD_SIZE.=C2=A0= Do you >>>> agree? >>>> >>> Not exactly. We need to consider for vma which span at least one >>> PUD_SIZE after align its vm_start and vm_end. >>> >> >> I know that I provided an incorrect example again.=C2=A0 Sorry (again)= ! >> >> Can you provide an example where adding the simple check for vma size=20 >> less >> than PUD_SIZE to your original patch will not work.=C2=A0 The logic in= your V2 >> patch is correct.=C2=A0 However, I am having a hard time finding a pro= blem=20 >> with >> this simpler approach. >> >=20 >=20 > Thanks for checking. An example like this: > (vm_start, vm_end) =3D (2G - 6M, 2G+8M), so this vma is bigger than > PUD_SIZE, and the check for vma size bigger than PUD_SIZE will pass. >=20 > With (start, end) =3D (2G-4M, 2G-2M), the previous patch will not adjus= t > start(because adjust it from (2G-4M) to 1G will exceeding vm_start), bu= t > it will adjust end from (2G-2M) to 2G (because 2G still below vm_end). >=20 > The adjustment of end is incorrect, because (2G-6M, 2G) range of vma > is not allowed for PMD sharing(i.e., that range do not fully occupy > PUD_SIZE). If we make the wrong adjustment, then we will unnecessarily > impact to range (2G-2M, 2G). >=20 >=20 sorry, the above example is not correct for vma size, update it as below: (vm_start, vm_end) =3D (2G - 600M, 2G+800M), so this vma is bigger than PUD_SIZE, and the check for vma size bigger than PUD_SIZE will pass. With (start, end) =3D (2G-4M, 2G-2M), the previous patch will not adjust start(because adjust it from (2G-4M) to 1G will exceeding vm_start), but it will adjust end from (2G-2M) to 2G (because 2G still below vm_end). The adjustment of end is incorrect, because (2G-600M, 2G) range of vma is not allowed for PMD sharing(i.e., that range do not fully occupy PUD_SIZE). If we make the wrong adjustment, then we will unnecessarily impact to range (2G-2M, 2G).