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=-8.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 CE51CC433EF for ; Thu, 9 Sep 2021 06:17:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A0C161102 for ; Thu, 9 Sep 2021 06:17:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4A0C161102 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id CE194900002; Thu, 9 Sep 2021 02:17:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C6AAC6B0072; Thu, 9 Sep 2021 02:17:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0B0E900002; Thu, 9 Sep 2021 02:17:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id 98BE76B0071 for ; Thu, 9 Sep 2021 02:17:36 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2DF7727702 for ; Thu, 9 Sep 2021 06:17:36 +0000 (UTC) X-FDA: 78567028512.01.CC6D08E Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by imf21.hostedemail.com (Postfix) with ESMTP id DF061D02A743 for ; Thu, 9 Sep 2021 06:17:35 +0000 (UTC) Received: by mail-lj1-f171.google.com with SMTP id f2so1268075ljn.1 for ; Wed, 08 Sep 2021 23:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6jMBpmkSePi8Q+tjzlzHAw91s1TP7X0CnXJ0KmdHirc=; b=YWfZixjdK1spTMoY+DKK2RVGNam+gDZa9XXZshjr8WkTud98VrUKcYg2mpsfUQhRUJ NeS8wAb4xR+CeiY7S7YWeJs1n2F1rmwgzA5H8uzLe/rJ3o/x9lonfs5N5cFQUypUI61r j8Pj1ul2MQB1PTPl7qW41rkgoGLsiS0Vt4TojJiytNUsfKgeHqXFkfZpBE9OdGDtbQjd rWbfESzJJXasSBa4Wu/WrYPFs95c/+L7s4Wb6JNtUNQQN2lPLYFCbXS2UPCZ6I2qUh4Y ijCZ9tj4njnbZ7a7URbk1p/lT604hsUiLgQfiPkE5eKyJo1q3wXUuy2ptWYvtuxFXsJ0 1fRQ== 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=6jMBpmkSePi8Q+tjzlzHAw91s1TP7X0CnXJ0KmdHirc=; b=YOhhHpuxpRZ+73BwstPtAPze40ZtlseF5n0dbZF9fFBMOX9dNSJRNvyzik5as7dOE5 Vz2kQsjsSOC/ZzYs4s8BTEnFG3m6MnHy5ckNHt+uKOnQSYxRvs53v5VZDQ6uG/lpd62i Kh0paeTUuepuNlqj4vVjOb347H6vD+KEk5cM5xblffBHFxB3Q8TSmwHMVA+fyfncRtYU zucmSRo+MK6T3Y8X0pyidCkRJ/UgbS8cJXe3puIM6IEuBGgjxoN6ba3dE67l8M5TSV0O PnifH8RgdTHhOZnN0ayDFaGcHOU937uH5ZNyJxxk68Q7NRRmKC4pPGXpVejByUCKQruM rMGg== X-Gm-Message-State: AOAM5325xsUI6W86dVskujvJvgQCMaUGrD3Zmzvo3SCj8ud4r5/fnW7M E30B/p06APgCIJQuBYkCUqhugHZ5SQtCpg== X-Google-Smtp-Source: ABdhPJzb79sYeiW67woAU2L4IduTt4NiWhx/bQpljHERdeUzxLeeTCJBcOMp98yo0hN7hHObtp3r6A== X-Received: by 2002:a2e:824e:: with SMTP id j14mr954387ljh.65.1631168254321; Wed, 08 Sep 2021 23:17:34 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id y9sm87502ljm.5.2021.09.08.23.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 23:17:33 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id AA213102F11; Thu, 9 Sep 2021 09:17:32 +0300 (+03) Date: Thu, 9 Sep 2021 09:17:32 +0300 From: "Kirill A. Shutemov" To: Liu Yuntao Cc: akpm@linux-foundation.org, hughd@google.com, kirill.shutemov@linux.intel.com, 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() Message-ID: <20210909061732.2zalspiyfoevd7ea@box.shutemov.name> References: <20210909032007.18353-1-liuyuntao10@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210909032007.18353-1-liuyuntao10@huawei.com> X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: DF061D02A743 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=YWfZixjd; dmarc=none; spf=none (imf21.hostedemail.com: domain of kirill@shutemov.name has no SPF policy when checking 209.85.208.171) smtp.mailfrom=kirill@shutemov.name X-Stat-Signature: d1e39tsbyfr8yra4dqg4mmijypoyu66t X-HE-Tag: 1631168255-160259 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 Thu, Sep 09, 2021 at 11:20:07AM +0800, 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. > In shmem_is_huge(), the corresponding index happens to be 512. > After rounded up by HPAGE_PMD_NR, it will still be 512 which is > smaller than i_size, and shmem_is_huge() will return true. > As a result, my buffer takes an additional huge page, and that > shouldn't happen when shmem_enabled is set to within_size. > > Fixes: f3f0e1d2150b2b ("khugepaged: add support of collapse for tmpfs/shmem pages") > Signed-off-by: Liu Yuntao Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov