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 123B3C00140 for ; Tue, 2 Aug 2022 18:11:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A58486B0071; Tue, 2 Aug 2022 14:11:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A07B68E0005; Tue, 2 Aug 2022 14:11:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CF678E0003; Tue, 2 Aug 2022 14:11:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7DAD46B0071 for ; Tue, 2 Aug 2022 14:11:08 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4EE92140FB4 for ; Tue, 2 Aug 2022 18:11:08 +0000 (UTC) X-FDA: 79755444216.16.396741D Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf23.hostedemail.com (Postfix) with ESMTP id 8F7E814010C for ; Tue, 2 Aug 2022 18:11:06 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A8F3F381C5; Tue, 2 Aug 2022 18:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1659463864; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Pz4nohXMnV6DoQDiLTQldnM+q/whU1JUDeaFPyIhZ1g=; b=qbwOAxE67O43QdxlU3BgVNMFcqw+bIAks9zkzBZrdIt+p9QtP3Fv7xMPLaENAdVp7Aedx9 XzoRSqRbgRcLUXbFDFMud/GksDdqcgMn+9twIIJ4cRQFVh+siuSiTKL0Shqw/NSsGMSWNj Sj0WJF2iodrQNqR8K7qbSku3yKszI1E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1659463864; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Pz4nohXMnV6DoQDiLTQldnM+q/whU1JUDeaFPyIhZ1g=; b=B3fB4DC8HPOsEVk5KmGSn/lYbNT4tRMJqrUYo2XAEFOxE+jYElYC0WLOUq4qB59SfGVsCj 5wjm/c5z7w+cjuBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6C8841345B; Tue, 2 Aug 2022 18:11:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id LWGzGbho6WJzTgAAMHmgww (envelope-from ); Tue, 02 Aug 2022 18:11:04 +0000 Date: Tue, 2 Aug 2022 20:06:02 +0200 From: David Sterba To: alexlzhu@fb.com Cc: kernel-team@fb.com, linux-mm@kvack.org, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: fix alginment of VMA for memory mapped files on THP Message-ID: <20220802180602.GX13489@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, alexlzhu@fb.com, kernel-team@fb.com, linux-mm@kvack.org, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220801184740.2134364-1-alexlzhu@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220801184740.2134364-1-alexlzhu@fb.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659463866; a=rsa-sha256; cv=none; b=6q6kbkZCHBarNWrs07XN26V1HtqP8UbltbcnsTBiZ2L8iaN4iN7CCL4qQUzIIH6nKCgRED lOi8YwU7xfPb+pgbfOUlYmPnBaBV8BCKGgPfdmbxo8eUL+uJILSfWciq/P/5w0DpGEqKec AjpSxNPlnnoAy0YbE5tBhTH+9YKbJY0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=qbwOAxE6; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=B3fB4DC8; spf=pass (imf23.hostedemail.com: domain of dsterba@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=dsterba@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659463866; h=from:from:sender:reply-to: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=Pz4nohXMnV6DoQDiLTQldnM+q/whU1JUDeaFPyIhZ1g=; b=OOyUoTmTZjJIglCj3X9ep2IamOT41tlU3JVgQMLNm956K9c8e5KByMWUHXsL6ZPi8LrmKZ Ajg3QxNb3hvWDWA6NBeuofbCcch2vx8et/602Juu1IfHnUTMEW2OiATnVzGro2+ljJXagD ZBZBUK7OsrhVhlFJwOAzXdgb/eI4SE4= X-Rspam-User: X-Stat-Signature: 3mkrjwiodnba55fsje9z6aqchxd1dqzi X-Rspamd-Queue-Id: 8F7E814010C Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=qbwOAxE6; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=B3fB4DC8; spf=pass (imf23.hostedemail.com: domain of dsterba@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=dsterba@suse.cz; dmarc=none X-Rspamd-Server: rspam02 X-HE-Tag: 1659463866-411768 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 Mon, Aug 01, 2022 at 11:47:40AM -0700, alexlzhu@fb.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, 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 > thp_get_unmapped_area for the unmapped_area function in btrfs, which is > what ext2, ext4, fuse, and xfs all use. Commit dbe6ec815641 ("ext2/4, xfs: call thp_get_unmapped_area() for pmd mappings") adds the callback for DAX, that btrfs does not support so it was left out. > 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. > > Before this patch: > > 7fc6a7e18000-7fc6a80cc000 r-xp 00000000 00:1e 199856 > /usr/lib64/libcrypto.so.1.1.1k > Size: 2768 kB > THPeligible: 0 > VmFlags: rd ex mr mw me > > With this patch the library is mapped at a 2MB aligned address: > > fbdfe200000-7fbdfe4b4000 r-xp 00000000 00:1e 199856 > /usr/lib64/libcrypto.so.1.1.1k > Size: 2768 kB > THPeligible: 1 > VmFlags: rd ex mr mw me > > This fixes the alignment of VMAs for any mmap of a file that has the > rd and ex permissions and size >= 2MB. The VMA alignment and > THPeligible field for anonymous memory is handled separately and > is thus not effected by this change. > > Signed-off-by: alexlzhu Please use full name for signed-off. Also the subject should start with "btrfs:", this is not a memory management patch. Thanks.