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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 572A2C00144 for ; Fri, 29 Jul 2022 19:46:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2EB46B0071; Fri, 29 Jul 2022 15:46:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CDE7C6B0072; Fri, 29 Jul 2022 15:46:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA5F58E0001; Fri, 29 Jul 2022 15:46:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A94016B0071 for ; Fri, 29 Jul 2022 15:46:41 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8A853140171 for ; Fri, 29 Jul 2022 19:46:41 +0000 (UTC) X-FDA: 79741169802.05.9C24B62 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id ACDCC1400CB for ; Fri, 29 Jul 2022 19:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=7Uyb73v5rTeGi6O22hmhJ+u8gllUvmeLKJcs+R3V8JY=; b=fGF3arBN3qZwrpge7TrypIPvtU lqSRvYisb02UGydgHErTPZdJUjvC8IilC6S4OQ+JNwa+4MV37da9is0EM6tVOs8imwcccqdsuLEzs qDhvWgPZBdEgI2fiBKwXv6V0Ltaxje17UqBPUroWL4oqJCcrRny9j0na/OoOs0QYjw7k456Tqib0D IgyYXviQHOt808H80OQ1mCYrMjs1yB+Nda4h/F6y2pXpGcrPbns0M8tIn+0mFjJyzoOIWubHkOWn+ AD2gJDLSd7cVTdJJOFbvMKeGI4mOoAPF/zGpiPYjfwkMlO23ykt+frY8ddmhWhfKTpz0Jx44jkVbZ vs6YnXnw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHVwL-0050n0-CU; Fri, 29 Jul 2022 19:46:29 +0000 Date: Fri, 29 Jul 2022 20:46:29 +0100 From: Matthew Wilcox To: alexlzhu@fb.com Cc: linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/sys_x86_64: fix VMA alginment for mmap file to THP Message-ID: References: <20220729194214.1309313-1-alexlzhu@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220729194214.1309313-1-alexlzhu@fb.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659124000; a=rsa-sha256; cv=none; b=0TIY8H1mQqFFcbxVGtX8dKJDOVV/jPajMvr0//quf2+puz9Rfv914UmcfoNiQn/XVmgcvy DIooMbgvo4C5neTjwdgf8mKizY8uYq/uM6PtbLK0DQjpfFi6lD9ZHF3D7lzJ4dIzU2uqsD DzCITVSLi7vtuuKeIDKHF/B1HrvA34A= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fGF3arBN; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659124000; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7Uyb73v5rTeGi6O22hmhJ+u8gllUvmeLKJcs+R3V8JY=; b=eWIm6bH3lPf6//y+3q6/MqOcpb63weaqq387SOj/6fTZPQ/gLfDTSX619dJ3p1PTAgvsx2 sfzhIIxi3Vf4Y3MK7Ht6qcRf1SDdSrDN5f/+r14QQmJlZ4to9+D0j8NR6Xe2VXtPBdhoQH 3JRrgn1WSa7fsCimTEJ6kA2H4R+9lR8= X-Rspamd-Queue-Id: ACDCC1400CB X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fGF3arBN; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam09 X-Stat-Signature: 4wxxaw5zykuf1ngs39dtfwp3aikxtjic X-HE-Tag: 1659123999-764538 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 Fri, Jul 29, 2022 at 12:42:14PM -0700, alexlzhu@devvm6390.atn0.facebook.com wrote: > From: alexlzhu > > With CONFIG_READ_ONLY_THP_FOR_FS, the Linux kernel supports using THPs for > read-only mmapped files, such as shared libraries. However, on x86 the > kernel makes no attempt to actually align those mappings on 2MB boundaries, > which makes it impossible to use those THPs most of the time. This issue > applies to general file mapping THP as well as existing setups using > CONFIG_READ_ONLY_THP_FOR_FS. This is easily fixed by using the alignment > info passed to vm_unmapped_area. The problem can be seen in > /proc/PID/smaps where THPeligible is set to 0 on mappings to eligible > shared object files as shown below. Can't your filesystem just use thp_get_unmapped_area() like ext2/ext4/fuse/xfs do?