Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2672832imn; Tue, 2 Aug 2022 11:35:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tlyz02d9cah9+uAF5OhYRGyNggeLTGW3h7vblbOhELmh9Rf1N3kWQOO+pyY3vhWIRmVbeC X-Received: by 2002:a05:6402:500b:b0:431:78d0:bf9d with SMTP id p11-20020a056402500b00b0043178d0bf9dmr21863621eda.184.1659465331971; Tue, 02 Aug 2022 11:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659465331; cv=none; d=google.com; s=arc-20160816; b=omQjfDxv7uksLL/IsLZEUzOF1fWZ0kZgpHUev4gxjzeyZ/+VsLgjXgHM0MVcpjU4+b 7TTxUswbmc+7GpvCn6Gl7D852/RLYmY0gCfsnqqmliaBCPpNMqcRkMOz3h783uchF7vH NF3zBWv0AgtVxU4gaoskt+b9+DCAHC61KxsPtc5/BI65ZftGthbL4jl9+Ex3B7P+0OIs Scn76QKn93bP9IxSbsN7NSPl/6Uj0E6HGliBbSdmx09hOmvJYo4SSh/l0Fn1xQ89dI9j BTEH3WjZkCv7tdc3xIPIPCoQt7k8OXKibk/FcdbKx8FInRvf63bAl1xIHMfZhTwTF1BZ 9XUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=Pz4nohXMnV6DoQDiLTQldnM+q/whU1JUDeaFPyIhZ1g=; b=Ss151Z1OAoIXt4svFzswahC7cXHsonhEUB37CP0W1uk4xF6wqbFeIA2yY6BQgLODkN xQVvxRBqv5txfXJCCizoDyJmH23BS4fOZceNeGrz5erYbHntzpgNEbMp+cfuT3SZ4abg H01H6KoIEyPPkbyjSx6OO+fCojdPWecGHBBEX9/o3IK5T1CanRMZVQeQYZE5iRT/FxxH 0N/V7GNDttyjM/U6fDjPb7vw/YKFFkDvoH9aEjg0NzSSYuROhPo336mARWHcqezokq9D uL/k9AaLMV+cAnMu9zoSf60Fw3fo4MSsOAI50xXz+XJIPgMcxSTSjEebhBewDKoAAYpi 2v8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qbwOAxE6; dkim=neutral (no key) header.i=@suse.cz header.b=B3fB4DC8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs8-20020a1709072d0800b007309a1b326dsi986958ejc.704.2022.08.02.11.35.06; Tue, 02 Aug 2022 11:35:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qbwOAxE6; dkim=neutral (no key) header.i=@suse.cz header.b=B3fB4DC8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234170AbiHBSLb (ORCPT + 99 others); Tue, 2 Aug 2022 14:11:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237846AbiHBSLJ (ORCPT ); Tue, 2 Aug 2022 14:11:09 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD0517E1C; Tue, 2 Aug 2022 11:11:05 -0700 (PDT) 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) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.