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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE47FC433EF for ; Sun, 26 Sep 2021 20:01:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 454EA60F6D for ; Sun, 26 Sep 2021 20:01:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 454EA60F6D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4850B900002; Sun, 26 Sep 2021 16:01:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 432EC6B0072; Sun, 26 Sep 2021 16:01:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FAA6900002; Sun, 26 Sep 2021 16:01:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 201DB6B0071 for ; Sun, 26 Sep 2021 16:01:38 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C40EC8249980 for ; Sun, 26 Sep 2021 20:01:37 +0000 (UTC) X-FDA: 78630794634.34.1193748 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) by imf07.hostedemail.com (Postfix) with ESMTP id 6F57710000A7 for ; Sun, 26 Sep 2021 20:01:37 +0000 (UTC) Received: by mail-oi1-f171.google.com with SMTP id w206so22777060oiw.4 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=YYQOU8UO9YgGufXNbJzhV8MBdNczPWieodY9tjnLwg8MPKxVMKz9rMN2q+YWbKnH3F mNxWlMQ1JewcHSfRsO5BPz/HesPXFp7FJlckbQeqGiSrDa7oM30PBzdwiM/0NNuuOiWi h4Jg5ByFMqAEO8ZlZ8m39a2lJKR4qt9VDUQnUMAgX7ISmfIPoIn9qRCLjowFdPbFasC/ lMsa2USVdgNWD4cn6s/gI/bMGZ/KNrY2eNCA7V6hUG7T9d7+QPUDsa7Ju0qTkL9PeGfd RzPeedrxjeerswEUyo6f+1JHgaUlku/WYuf5xQPkmTeZfu6Ot1nPc7pVzRWc/LS4FVFE 2uMw== X-Gm-Message-State: AOAM533p0MpSL4Uu+BXwzzERyqK3uNWTWwK1KyfssWR4qsI+uA3X2HCD pGcpvfZ+IA/MCleA79YIFWVjXw== X-Google-Smtp-Source: ABdhPJx/Jtc2vnPaAEl/lYrasw3bxw2ZwcVy1vVPt9ZezefP6jfZJid8wAWv9Pmgd5C+CmpPqPjVPg== 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 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6F57710000A7 X-Stat-Signature: ba36m49iw4x6rpzejbrj73djafkbhsik Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=k66FBV1f; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.167.171 as permitted sender) smtp.mailfrom=hughd@google.com X-HE-Tag: 1632686497-264341 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 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