Received: by 10.192.165.148 with SMTP id m20csp797703imm; Wed, 25 Apr 2018 07:51:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx48MEt553zet2mcdoiKC+J230q4eX+mZYmBc4xg3aODGEw3pXzM93zU+xsDg7/9Bku1Y203v X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr29360280pla.205.1524667866620; Wed, 25 Apr 2018 07:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524667866; cv=none; d=google.com; s=arc-20160816; b=ZvS1egd5gBbNbveoYL4rssIybKhzsZS1ScXvIfBbznN5PRXpCQzQK4jCaIN7A2Nuec EL48e2Oy9bRUK59XJmGKakvvKSqJr7WX2lHzgI/TWvmB0iQ3UojCLPIenb5NapGciuXo EYVCp0JWRSDP5UsmbNR1u7hPr16r4V1vExDwR5agnyTs0Ut9x+i2pAoAxL5YAw5OUgam LQiFmGa6D4yZJ1cLNQxp96i/F6WssZeSU9xZ1sLfZ/3E+oJQdi9pNCka8BlvNz7z3Cqj TQle0grXFhSMcFipt9YwYHT7KkI18WxXVmbUdf6dPz9kA9jk5eMAYNoWs30l4bLmxl1V VOdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=cRSYwnCvki4gjjvSddC4N6fdbxfYH5HFL34bS8gFTqg=; b=yWcS1rrXu20+8rXwb2jYhav5f297G625fav9T9Sd5dzyDmmp1I+Jo7+xfZVWdpb6Qt wDKmmZf2ewMZOe33RDfDM6ZtlbqZZrtB6DydyBBvwRQOnPt0wD6mecK3Jxt7slHOrJZ/ 58Ki3zsvqILpmOJ1fJ8C6CuKQEHIxTmMd8KzXx3BgJM+z6oKyb1kaHy8LcCYUJ8rEvQi ZnLc4GyWA0+ehr9WFLMqKu5hhxcKcKn06eGEFAkXyOM4c4zrh6Y6TWHAJKBFDCdXrqg0 V/FWCBDH28DkEkIQ4RUspfnq/30g48ZHdEuyTSPLU2uR0TUG26i02XCebrZnVO/V0tdz LNig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=bAuAqtdJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l67si2311993pfg.326.2018.04.25.07.50.51; Wed, 25 Apr 2018 07:51:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=bAuAqtdJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754735AbeDYOtn (ORCPT + 99 others); Wed, 25 Apr 2018 10:49:43 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:43662 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754562AbeDYOtj (ORCPT ); Wed, 25 Apr 2018 10:49:39 -0400 Received: by mail-pg0-f67.google.com with SMTP id f132so13502886pgc.10 for ; Wed, 25 Apr 2018 07:49:39 -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:user-agent; bh=cRSYwnCvki4gjjvSddC4N6fdbxfYH5HFL34bS8gFTqg=; b=bAuAqtdJqXyZskOLIRn4RB/3tv4POKuJx3V03BLbJilBLjhY/WIFGVEE/yyufY6HvI 1YTnarM033z37dazHdVnjJYdM2zpKYhziFcMqL0+kvKIS3BJPAf9fFYftntXzWUJxBTs maPbYPUSb61IvU+ApwfFgLeSoJNFFKIfq2nJqBdF6JYHSqW0LSkn1Bhmo9BaOlA3H/hG E9n7a4NZBbsX7uvcW5AoXF3Gec9y1zPOfG0STHywiHHfZJOoUyJ4bQk0qbDPMwWZZjNs O0PjtJt8CddRJv4mPDJrJPrrGDx04HMAYv4E7NO2L6G8+2j/gqw2X6Wbt4/v7jF7LJUw Xy/A== 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:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cRSYwnCvki4gjjvSddC4N6fdbxfYH5HFL34bS8gFTqg=; b=Sj8IsE8sNrJlUXpOCSEs1AzbWKGI1bLNRCWzqjcoBY91GRvtp12GAXcNzXGhH9TLfy Iblsf+NKLCKPdUncAKIKOtsiFv4hoUI5OsZaBFRyhAqonrjNEgr2JAwSRzrbIqmjfQ8b RlDGXDppopmk0QcmuN+4SFbqcADZPvI76Yzj6cQstjsfqWHr4SArO65EbairDozM6viF xsXwrCXuBgoNy3tC+j4FFTg5W3yXZaL5ubY4AEeOcsWJfbgmPwerknct6GzZnbhXwOjx vm+6rkFLEo4DywQEVFjipAVFX8OkFej0lK8sy0UADKYBC1GbqpuFXUpAxx9feFFII+Nt cy+g== X-Gm-Message-State: ALQs6tCw7SU/6nCXDXDhSn6x9sHS5Hk0tEd1ioerGcjuu7ofm1BG7LTB ervPpx7GKRl6zAG/Lsgf51JOZw== X-Received: by 10.99.0.200 with SMTP id 191mr23964750pga.33.1524667779162; Wed, 25 Apr 2018 07:49:39 -0700 (PDT) Received: from kshutemo-mobl1.localdomain ([198.233.165.212]) by smtp.gmail.com with ESMTPSA id r8sm28184119pgn.19.2018.04.25.07.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 07:49:37 -0700 (PDT) Received: by kshutemo-mobl1.localdomain (Postfix, from userid 1000) id E36DA309294; Wed, 25 Apr 2018 17:49:38 +0300 (+03) Date: Wed, 25 Apr 2018 17:49:38 +0300 From: "Kirill A. Shutemov" To: Yang Shi Cc: kirill.shutemov@linux.intel.com, hughd@google.com, mhocko@kernel.org, hch@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC v5 PATCH] mm: shmem: make stat.st_blksize return huge page size if THP is on Message-ID: <20180425144938.6mv7idgd2u2cyucu@kshutemo-mobl1> References: <1524665633-83806-1-git-send-email-yang.shi@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1524665633-83806-1-git-send-email-yang.shi@linux.alibaba.com> User-Agent: NeoMutt/20180323 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 25, 2018 at 10:13:53PM +0800, Yang Shi wrote: > Since tmpfs THP was supported in 4.8, hugetlbfs is not the only > filesystem with huge page support anymore. tmpfs can use huge page via > THP when mounting by "huge=" mount option. > > When applications use huge page on hugetlbfs, it just need check the > filesystem magic number, but it is not enough for tmpfs. Make > stat.st_blksize return huge page size if it is mounted by appropriate > "huge=" option to give applications a hint to optimize the behavior with > THP. > > Some applications may not do wisely with THP. For example, QEMU may mmap > file on non huge page aligned hint address with MAP_FIXED, which results > in no pages are PMD mapped even though THP is used. Some applications > may mmap file with non huge page aligned offset. Both behaviors make THP > pointless. > > statfs.f_bsize still returns 4KB for tmpfs since THP could be split, and it > also may fallback to 4KB page silently if there is not enough huge page. > Furthermore, different f_bsize makes max_blocks and free_blocks > calculation harder but without too much benefit. Returning huge page > size via stat.st_blksize sounds good enough. > > Since PUD size huge page for THP has not been supported, now it just > returns HPAGE_PMD_SIZE. > > Signed-off-by: Yang Shi > Cc: "Kirill A. Shutemov" > Cc: Hugh Dickins > Cc: Michal Hocko > Cc: Alexander Viro > Suggested-by: Christoph Hellwig Looks good to me: Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov