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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7656EC4829E for ; Fri, 16 Feb 2024 00:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ahnJXUH/TC9XUYZ1CaSLOODJ4r876v0kGNQ02vhOYAs=; b=bCyD4HPSm/BIZP XEig+qTNlcfYtfD7+BfxiadBIuzeTM73IkoR6TggdBjlOBQmDwI0OnSRjSHthCtcQjC6N5BHp7gsH yO8snglpYEZ3O++FwIAAE7+Xa3tKGdt1dsdRnpyhlxbm3Pv4FUN3xg4hB9J93K2AyyiGEVyp6fPLu F4+kUHwbPytvx5+Hs1HyqmOvoLERI1XkKHjmIXJx0+x41CIWWoJDSuIr84baIk32GzgmaxA06GKzL 06pjcnH8XHKnh+RUf/6yydyL420EhjlurdeP4yTO0izjsze8b/a2fLWzp9WAptja4ArbGkXol1XbH yqziU5O0lxd7qMATwFCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rali4-00000000Y7L-0sdD; Fri, 16 Feb 2024 00:04:08 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rali0-00000000Y6W-3Uey for linux-arm-kernel@lists.infradead.org; Fri, 16 Feb 2024 00:04:06 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6e09493eb8eso2042573b3a.1 for ; Thu, 15 Feb 2024 16:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1708041844; x=1708646644; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=B+hW1/MwR04S4IUgIII8rEgyOltSHRihojBGlZc3thU=; b=EnbPRaJBwh4DFsMZrp8ogSZKdVewMy2OEoBY7onocthhebYiXN1FuR95yhC7fjwFyi oqQBm/1Sp53Y/v9BuBtRH3Ougi1yK3DlYY+I/hOiLjnWcodWTdFzMSAsj7RQYuc0Wii/ OSqWhfyiBYOvZ/pBWJ8CmbnierNg0sU0zeFsI5zvSscI6JTum9Mo33yLKu+6AJVFon6J 7MTvRXG10ojD/w3FiwNAZLq67qsdQx4wTVUJFUeWS9EaRvmTBRG0lTAoaX1zILwOVF4K YAnV1DWGA0tq7IHzcEi/f3iyMmqZGC186FJtGg/ugk5NLK9SagtyHPTIur6VylEeaYHw iuWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708041844; x=1708646644; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=B+hW1/MwR04S4IUgIII8rEgyOltSHRihojBGlZc3thU=; b=nzJ6WKZf/rVZlDvii2s2ncreCwqsKbKj5nHCGeWROpiQ5+250tPOeUz6w72PvpAHnd AL+iVrc31CqhWC2EWX4WkzkbZ2/frD0JnTPg5MvjBAWtdyUn3/YlSd19dSSP+vnm0uoF 1wAWB2SaLUluA5ieY4E1Mw04DoUZikFXlesy7kyLOzqzjrzoiw/bj/uRfSJFzw9OU/PZ CZZE9takZ4PfyroCUWP6z4tcy/O2wpEbTXhTzADGJu6aISMn9CsETX6EtpvwmK8yTavg LFkwnl/yUImiRhOfrUUV2Of6T5Pu+9dZzHLBDylo39isKyAIvj5CetJ3SNxbwlOlciBT TFSA== X-Forwarded-Encrypted: i=1; AJvYcCXWGe/I4ZLEnkntG6iEBhy9KMQxcp6WuknhuGnx6r/fcU3nOct4neosC9z5O5Evm87rgpk5YbhMoujPMYB3IS9iFFduTEl98X8n2ZqC9mBU0jla4Qg= X-Gm-Message-State: AOJu0Yz4M7g2W7d/iTiD2mhw8dfmsV1ti49+vQb2R90mJ90YyBLGhh3t a19H6RlikbzwtF4TWCkWjddCu4ua9frvRbl5tIIdzpXfo7rBTfcTpyKTcRIz7HM= X-Google-Smtp-Source: AGHT+IGK13f/ddwLuPDd7VBJvpcBJliwQaaFIZvWhXTQpf0/0SU9Fo3kjiG0dUjoKg8zCluHKNB/DA== X-Received: by 2002:a05:6a21:2d0c:b0:19e:c9e8:f2bc with SMTP id tw12-20020a056a212d0c00b0019ec9e8f2bcmr5193728pzb.15.1708041843767; Thu, 15 Feb 2024 16:04:03 -0800 (PST) Received: from dread.disaster.area (pa49-195-8-86.pa.nsw.optusnet.com.au. [49.195.8.86]) by smtp.gmail.com with ESMTPSA id p37-20020a056a0026e500b006db9604bf8csm1889606pfw.131.2024.02.15.16.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 16:04:03 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1ralhw-0073PF-1Q; Fri, 16 Feb 2024 11:04:00 +1100 Date: Fri, 16 Feb 2024 11:04:00 +1100 From: Dave Chinner To: Ryan Roberts Cc: Catalin Marinas , Will Deacon , Mark Rutland , "Matthew Wilcox (Oracle)" , Andrew Morton , David Hildenbrand , Barry Song <21cnbao@gmail.com>, John Hubbard , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm/filemap: Allow arch to request folio size for exec memory Message-ID: References: <20240215154059.2863126-1-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240215154059.2863126-1-ryan.roberts@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_160405_126984_0456CBC9 X-CRM114-Status: GOOD ( 22.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Feb 15, 2024 at 03:40:59PM +0000, Ryan Roberts wrote: > Change the readahead config so that if it is being requested for an > executable mapping, do a synchronous read of an arch-specified size in a > naturally aligned manner. > > On arm64 if memory is physically contiguous and naturally aligned to the > "contpte" size, we can use contpte mappings, which improves utilization > of the TLB. When paired with the "multi-size THP" changes, this works > well to reduce dTLB pressure. However iTLB pressure is still high due to > executable mappings having a low liklihood of being in the required > folio size and mapping alignment, even when the filesystem supports > readahead into large folios (e.g. XFS). > > The reason for the low liklihood is that the current readahead algorithm > starts with an order-2 folio and increases the folio order by 2 every > time the readahead mark is hit. But most executable memory is faulted in > fairly randomly and so the readahead mark is rarely hit and most > executable folios remain order-2. Yup, this is a bug in the readahead code, and really has nothing to do with executable files, mmap or the architecture. We don't want some magic new VM_EXEC min folio size per architecture thingy to be set - we just want readahead to do the right thing. Indeed, we are already adding a mapping minimum folio order directive to the address space to allow for filesystem block sizes greater than PAGE_SIZE. That's the generic mechanism that this functionality requires. See here: https://lore.kernel.org/linux-xfs/20240213093713.1753368-5-kernel@pankajraghav.com/ (Probably worth reading some of the other readahead mods in that series and the discussion because readahead needs to ensure that it fill entire high order folios in a single IO to avoid partial folio up-to-date states from partial reads.) IOWs, it seems to me that we could use this proposed generic mapping min order functionality when mmap() is run and VM_EXEC is set to set the min order to, say, 64kB. Then the readahead code would simply do the right thing, as would all other reads and writes to that mapping. We could trigger this in the ->mmap() method of the filesystem so that filesysetms that can use large folios can turn it on, whilst other filesystems remain blissfully unaware of the functionality. Filesystems could also do smarter things here, too. eg. enable PMD alignment for large mapped files.... -Dave. -- Dave Chinner david@fromorbit.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel