From patchwork Tue Aug 17 08:22:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12440871 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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL 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 B75FAC4338F for ; Tue, 17 Aug 2021 08:22:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 62CBC60F41 for ; Tue, 17 Aug 2021 08:22:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 62CBC60F41 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 F357B8D0001; Tue, 17 Aug 2021 04:22:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE5F46B0074; Tue, 17 Aug 2021 04:22:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAF8C8D0001; Tue, 17 Aug 2021 04:22:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0186.hostedemail.com [216.40.44.186]) by kanga.kvack.org (Postfix) with ESMTP id BD9526B0073 for ; Tue, 17 Aug 2021 04:22:43 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 663BD183F68D7 for ; Tue, 17 Aug 2021 08:22:43 +0000 (UTC) X-FDA: 78483881406.04.4B930D6 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by imf02.hostedemail.com (Postfix) with ESMTP id 20E93700CBC6 for ; Tue, 17 Aug 2021 08:22:43 +0000 (UTC) Received: by mail-qk1-f171.google.com with SMTP id p22so20947599qki.10 for ; Tue, 17 Aug 2021 01:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=uMoWHC9cCmkGmKGRd5MKhVSuBe7FnrhK9vgIvOjVdUQ=; b=ZBCIu8JrSYXp32UHfr0V7Utr7kxWRAe1330WqMcSxMAU6EkiQqUl+y1J5Qgw9zu6HD NbkPMfRczuZxY7kB6NMOGMop7Adk9XdWy838R5kRiHLdhQnSwo+amn5PLFOZlFHq4xxu fuiU/mu3Z1aAmGE7CU3PikodGjnJJAXDr6m6cRNcOYdL7N1MEgpdgWzqOSxyRIHdrPGM eNZoVBUcsUl/lVaaIPFBHo1n96GV6/jnDvZpc8M88qKmmCutIfCz0r1Pwv550TNDZfb3 f5S0fTAcV1CggoawTLJg1zAyNa3uWYd8wePzYvXiseBVnqgsTnVYdKMYF4M1crB/QQrX fFfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=uMoWHC9cCmkGmKGRd5MKhVSuBe7FnrhK9vgIvOjVdUQ=; b=ZH/XpRwgB/CZH/NI6B1aEY/IgH75+mLoe6Ugd6L/IJaRevGL4Dh4lFbxKqUxMtfNlI 19RIjvYn7iFmNI5C9p78JmNNeLHtN/RXpcRDhExDFJ3OuGcuSwAEdszrzajh44Nollai eQheKyudhIVZz4h9o5vH8QMzegupOP5NbM/PVgAES5FShgV1hjNpOpTeZf99Ho2FwTJx pR0aaxNjbXDiMmD+BmULXsGrw9niQKom3JRBNAsBdTWo5VTCJcjZ6pDlIGrIcRAynuKd 1QJVyH3Zb4ggXmq/Nl39mB9MoVXAZ4YdEAshKPbHorC28UoaiCb13I9RJCIGejcrrkRg 2Zlw== X-Gm-Message-State: AOAM530z1Z7pBWJhr0lbnpylJlZSwfPibHXk1pUioxFFdWYekWkr5T/Y HwZHCZZANhFqXRaNIDxpnW1mRw== X-Google-Smtp-Source: ABdhPJysm9W9si8YZq6HQ/Q9doxawpakksZKCtswsPYBwhARLV5gH6YuEjM4S4T/sg5Os7AMzVnpvA== X-Received: by 2002:a05:620a:16b7:: with SMTP id s23mr2582871qkj.154.1629188562319; Tue, 17 Aug 2021 01:22:42 -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 b25sm499732qka.23.2021.08.17.01.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Aug 2021 01:22:41 -0700 (PDT) Date: Tue, 17 Aug 2021 01:22:39 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Andrew Morton cc: Hugh Dickins , Shakeel Butt , "Kirill A. Shutemov" , Yang Shi , Miaohe Lin , Mike Kravetz , Michal Hocko , Rik van Riel , Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 8/9] huge tmpfs: decide stat.st_blksize by shmem_is_huge() In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 20E93700CBC6 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=ZBCIu8Jr; spf=pass (imf02.hostedemail.com: domain of hughd@google.com designates 209.85.222.171 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam01 X-Stat-Signature: z6oy4z6jbju8fyfshrgagq4f9zdqnmon X-HE-Tag: 1629188563-27803 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: 4.18 commit 89fdcd262fd4 ("mm: shmem: make stat.st_blksize return huge page size if THP is on") added is_huge_enabled() to decide st_blksize: if hugeness is to be defined per file, that will need to be replaced by shmem_is_huge(). This does give a different answer (No) for small files on a "huge=within_size" mount: but that can be considered a minor bugfix. And a different answer (No) for default files on a "huge=advise" mount: I'm reluctant to complicate it, just to reproduce the same debatable answer as before. Signed-off-by: Hugh Dickins Reviewed-by: Yang Shi --- mm/shmem.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 56ee56b1cab6..b60a7abff27d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -689,15 +689,6 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ -static inline bool is_huge_enabled(struct shmem_sb_info *sbinfo) -{ - if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - (shmem_huge == SHMEM_HUGE_FORCE || sbinfo->huge) && - shmem_huge != SHMEM_HUGE_DENY) - return true; - return false; -} - /* * Like add_to_page_cache_locked, but error if expected item has gone. */ @@ -1078,7 +1069,6 @@ static int shmem_getattr(struct user_namespace *mnt_userns, { struct inode *inode = path->dentry->d_inode; struct shmem_inode_info *info = SHMEM_I(inode); - struct shmem_sb_info *sb_info = SHMEM_SB(inode->i_sb); if (info->alloced - info->swapped != inode->i_mapping->nrpages) { spin_lock_irq(&info->lock); @@ -1087,7 +1077,7 @@ static int shmem_getattr(struct user_namespace *mnt_userns, } generic_fillattr(&init_user_ns, inode, stat); - if (is_huge_enabled(sb_info)) + if (shmem_is_huge(NULL, inode, 0)) stat->blksize = HPAGE_PMD_SIZE; return 0;