Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1156741pxu; Fri, 27 Nov 2020 00:43:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhA7k48FpSej2sedyFwyj6OJELbFEB+jvi1K8Io62He8dm+El/+9j3vUlIuLmdqJFqjlo/ X-Received: by 2002:a50:a444:: with SMTP id v4mr6371743edb.175.1606466596855; Fri, 27 Nov 2020 00:43:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466596; cv=none; d=google.com; s=arc-20160816; b=JeEkb6mXRTGkjiUGdMx5tfejZnEVrMi7KxD0rS4c2XY4wcpi6oxaC0sbTyO1OeZGRP 5PZC3QqOwbupSlpDp/oF2FsCR/VCSYLzCatjPN/qEapYqrW0JgERY4IYCBSDH9du3+Ic gohNLsP1DLj8Eo7ozoaiC8+wdbLpoa+mtNgw8SbDpvXc32aXVXQd/SqksQXxIfCT0OH3 Njsc3y19zwj1k0yhzA/DtmPDTZO1MIqpL0POwRvToPwz8MVZQHFUm/S45Th+o04V8qaL lXmMekqLjfji3DGZckJI7I0+plTOcRfKexHo2oJnth5bJlpRhh3WMvcN4+INaThzu+If zhPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject; bh=7WkFxlbiDarlVjk6J2ojgv4988k/vivmxaIy6AWJUlM=; b=mXLVn5j+7nyNjduF7z40kieG/zFyq+fD7QxVUG3IOLzhO56WuZtd9xtKuHX//l05Ee 31Pb1gOnW3ez1lGR/L2DW21brns/FaKDbfJEy7PtTWxkXSKWj98qFqMBrwM3mc4ik2BX XactVV2z8N8mgjn00/LLDpMKz92Ijm+vjtIxZF/EWDj5y33zfFgyjBeZvrKgCdEeESJH s6g9lEcQ5NoUVSibchRNldLxtiJOs32YHW0tVkEd8TYtfsXpop1bpQiL5a4U4aQiQYBx XsNqBGwxHA7t9DGiJBEl6ogRwkRtm+rRtR5MtIli2sbhMzFN802GMsscC/mMWr246e+u kmGw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si1065824edh.221.2020.11.27.00.42.54; Fri, 27 Nov 2020 00:43:16 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404970AbgKZTrX (ORCPT + 99 others); Thu, 26 Nov 2020 14:47:23 -0500 Received: from mx2.suse.de ([195.135.220.15]:54380 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbgKZTrV (ORCPT ); Thu, 26 Nov 2020 14:47:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E852BACEB; Thu, 26 Nov 2020 19:47:19 +0000 (UTC) Subject: Re: [PATCH 3/3] mm,thp,shmem: make khugepaged obey tmpfs mount flags To: Rik van Riel , hughd@google.com Cc: xuyu@linux.alibaba.com, akpm@linux-foundation.org, mgorman@suse.de, aarcange@redhat.com, willy@infradead.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, linux-mm@kvack.org, mhocko@suse.com References: <20201124194925.623931-1-riel@surriel.com> <20201124194925.623931-4-riel@surriel.com> <8f2428a049f2c29f092782699bcb3af76bf72b6a.camel@surriel.com> From: Vlastimil Babka Autocrypt: addr=vbabka@suse.cz; prefer-encrypt=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/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <8f2428a049f2c29f092782699bcb3af76bf72b6a.camel@surriel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/26/20 7:14 PM, Rik van Riel wrote: > On Thu, 2020-11-26 at 18:18 +0100, Vlastimil Babka wrote: >> On 11/24/20 8:49 PM, Rik van Riel wrote: >>> Currently if thp enabled=[madvise], mounting a tmpfs filesystem >>> with huge=always and mmapping files from that tmpfs does not >>> result in khugepaged collapsing those mappings, despite the >>> mount flag indicating that it should. >>> >>> Fix that by breaking up the blocks of tests in hugepage_vma_check >>> a little bit, and testing things in the correct order. >>> >>> Signed-off-by: Rik van Riel >>> Fixes: c2231020ea7b ("mm: thp: register mm for khugepaged when >>> merging vma for shmem") >> >> Looks ok. But, it we have sysfs thp enabled=never, and shmem mount >> explicitly >> thp enabled, then shmem mount overrides the global sysfs setting and >> thp's will >> be allocated there, right? However, khugepaged_enabled() will be >> false and thus >> khugepaged won't run at all? So a similar situation than what you're >> fixing here. > > Indeed, that is somewhat similar. Whether or not shmem > allocations attempt huge pages is controlled by both > the file /sys/kernel/mm/transparent_hugepage/shmem_enabled Ah right, there's also that sysfs file. > and mount options. > > This patch makes khugepaged treat the mount options > and/or > sysfs flag as enabling collapsing of huge pages in case > enabled = [always] for regular THPs. > > Should I send another patch on top > of this that causes > khugepaged to be enabled when regular THPs are disabled, > but shmem THPs are enabled in any way? I think it would make sense. Although it might involve counting thp-enabled shmem mounts and only run khugepaged when there are >0 of them.