Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3369523pxb; Sun, 26 Sep 2021 13:05:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygqbsJ2OAM1pZxG0YGq8TL6YpopS9okUsiG7Pr4qA4sXC+/Tyk9k1zQOow1Ed/e/HFeqVW X-Received: by 2002:a50:d88d:: with SMTP id p13mr19132209edj.142.1632686754441; Sun, 26 Sep 2021 13:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632686754; cv=none; d=google.com; s=arc-20160816; b=PawoCn/1WWqN+tkwep2klfrvnO+x9Zx4dasU9290ljtMDeET6kUiiCOYJM5uww1t5R TQLkw/bBEv7uL8STzr//7uYxblJX2PZHKIilb2apvjU+YTxto42OiAgq13ztQMWLuvUz Zq1rh5KOy28DOfokjOcIXBSGr4+OHt/2fZTUBQTrrjCSme3eF6xSlZjRdGCkWs5hHfjS T/ewkvrRIhJThNuHNDax/1zzIu/bjU7S5W7Y5H8H8uZGN+a17qJCeh1rihfiAmqBWfQb i97FfL8E3rvkKmh5chgkAB422HRlXhVCUVzBNd6S3t1MN/ikJIIMhdK/T3/ISmMN8FjY mqLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=4i0ebcgiZSt3iiIIOoOHYoxW7mqy1o//v1PH4SJkf08=; b=ObF974rGdIUrVwS7ib35q5dJXq+r/A2sqdwxbD2BIUJoSG5Bgl+1SpkWZpHiiIPjzg ADUOG5MIzDOIEbc5iAwPZ5J/RsBeEEpriIP6MvuLU/hypmP6KYZh28IQg4IXcGefJRXp P0JwNioani0B8xDgW1RflE+B2w3IoDeYu+B/1W6WJZ2fFgIky/ZFxoaXHVfLlf6PXff/ FsOGgHp3Y4+h+Alb3FullPGU4lZxyBNb8hAJySNPYSF5XCxnkIMdj+RnIf0zwTH1X/0q LDwaKFk+6++/imvEQ0tmvaLnWu11dbLC58wcZoOqBTUJImX2VjSdZ3k33T/XWl9rG/eL Ka6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=k66FBV1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si21422768edj.62.2021.09.26.13.05.30; Sun, 26 Sep 2021 13:05:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=k66FBV1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230021AbhIZUDP (ORCPT + 99 others); Sun, 26 Sep 2021 16:03:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhIZUDO (ORCPT ); Sun, 26 Sep 2021 16:03:14 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B366AC061570 for ; Sun, 26 Sep 2021 13:01:37 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id s69so22653428oie.13 for ; Sun, 26 Sep 2021 13:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=4i0ebcgiZSt3iiIIOoOHYoxW7mqy1o//v1PH4SJkf08=; b=k66FBV1fxgJAOaMfc22JHJVjRD64cFQRTI28+9JDWm2+GCiACg8hB1gxPS2NPERyMh yaYjpoyKJRegO56P+NZx8xfGcO6r+EYUYlEKWTbgzQQWqWmc8yzw4QsmeDRRh5vPseI9 /exdpKUc+ZVJWV0nK3YoLjhkjHT6Feg8bgvlWM35b4iP0eBnv3qrO30lOFAnqszvrXuE Mtx9KE04Na19aomkyFMUC4HE4JOcmHDDWmbXJZlX4IJUJnU5A/3b9TBBsXKgxVtsY63K nMrxOLHHArVoRcuENVAVECRMPa1pmyXYGu7T2LV6VUwT7FX8FZlplvwbW08bL99VsWQC L9YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=4i0ebcgiZSt3iiIIOoOHYoxW7mqy1o//v1PH4SJkf08=; b=t45ywSswYJBvI3UHOARDXMtig/ivvO9pPynP5rXVIM0Ut3Tu6ftimYA/ehGPeob+mJ zhWIJ7ze2TUxbE1bdjjR88WJUq9KIxBH1A8uJqDhgNrP8BztrsvWY2zADe95PiwBbB40 EnGFpqiNkQiFFI9VIu0W8FlyegWzNcOFvGc29qqZTHwYGS591VDpdkt8VThebp7RzrYW GrCxuW9rPmNCqZaFpwRhDeM3fjyeZXLrO5FDMlBoyS+p1wqHVDpJaLELMgAMznuWD3FF q4Ets3E4/VXbwbdu0WJf79C5187LSUXU9aHg/qQB2SoabuxWzOTshNfR6kwoQrODigdp QzXg== X-Gm-Message-State: AOAM531jAMdyk847ERV3Lu9ovyB6bTRWCgzyKwposGx5UguYr+Gw7lPP v0qg6yfHQc+SC3Ex4ewn5waqrQx34TAMDA== X-Received: by 2002:aca:bec2:: with SMTP id o185mr9463615oif.30.1632686496463; Sun, 26 Sep 2021 13:01:36 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id i25sm3624270oto.26.2021.09.26.13.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 13:01:35 -0700 (PDT) Date: Sun, 26 Sep 2021 13:01:21 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: liuyuntao cc: hughd@google.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, kirill@shutemov.name, linux-kernel@vger.kernel.org, linux-mm@kvack.org, liusirui@huawei.com, windspectator@gmail.com, wuxu.wu@huawei.com Subject: Re: [PATCH v2] fix judgment error in shmem_is_huge() In-Reply-To: <20210926064201.3416154-1-liuyuntao10@huawei.com> Message-ID: References: <614538e2-16bb-2657-f374-64195c5c7c2@google.com> <20210926064201.3416154-1-liuyuntao10@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 26 Sep 2021, liuyuntao wrote: > On Sat, 25 Sep 2021, Hugh Dickins wrote: > > On Fri, 24 Sep 2021, Hugh Dickins wrote: > > > On Thu, 9 Sep 2021, Liu Yuntao wrote: > > > > > > > In the case of SHMEM_HUGE_WITHIN_SIZE, the page index is not rounded > > > > up correctly. When the page index points to the first page in a huge > > > > page, round_up() cannot bring it to the end of the huge page, but > > > > to the end of the previous one. > > > > > > > > an example: > > > > HPAGE_PMD_NR on my machine is 512(2 MB huge page size). > > > > After allcoating a 3000 KB buffer, I access it at location 2050 KB. > > > > > > Your example is certainly helpful, but weird! It's not impossible, > > > but wouldn't it be easier to understand if you said "2048 KB" there? > > I wanted to emphasize that access to any bit in the first page will > trigger this problem, so I didn't use "2048 KB". Okay, thanks, I see your point now. (And I have to admit that, in my confusion, I had thought 2050 KB would be index 514 - of course not!) > > > > In shmem_is_huge(), the corresponding index happens to be 512. ... > > Your patch makes within_size more sensible than it was for pre-sized > > files (and I think it's fair to say that the majority of files in > > shmem's internal mount, subject to thp/shmem_enabled, are likely to > > be fixed-size files); and better-defined than it used to be on > > growing files, but they won't get the huge pages they used to. > > Although my patch changes shmem's behaviour, it makes shmem consistent > with the documentation. I think with the new code, it will be easier > for our users to understand. Yes, I do agree with you. But the change in behaviour when appending at EOF is significant, and needed to be called out - I think none of quite realized that effect at first. Hugh