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 EF090C4829E for ; Fri, 16 Feb 2024 00:04:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76E3B8D0010; Thu, 15 Feb 2024 19:04:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71DFA8D0007; Thu, 15 Feb 2024 19:04:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BE1F8D0010; Thu, 15 Feb 2024 19:04:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4CA968D0007 for ; Thu, 15 Feb 2024 19:04:08 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0E1BE161CB2 for ; Fri, 16 Feb 2024 00:04:07 +0000 (UTC) X-FDA: 81795719334.26.D2CF4A9 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf10.hostedemail.com (Postfix) with ESMTP id 09238C001E for ; Fri, 16 Feb 2024 00:04:04 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=IfmHIA6s; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf10.hostedemail.com: domain of david@fromorbit.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708041845; 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=B+hW1/MwR04S4IUgIII8rEgyOltSHRihojBGlZc3thU=; b=5gGqVoCmGItf7ZafqCDtunSUO2Q2b2/vSeVgE5XYvnkqkOkVlJi9q6Sx5EnrmhjeooTCqC J99ZtPW0G24C1D/eLbDRa3lVJuszfNBZ8EbVy627wqcU/islT4xXsAESn+MuvZYCrwQcB2 CdGeigh0xTEVoXgw7039M/Wo4xU0ZZk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=IfmHIA6s; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf10.hostedemail.com: domain of david@fromorbit.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708041845; a=rsa-sha256; cv=none; b=qQzIjGyx6L0QxyXrg7KGy58QTv2pe69JyGvFfGlw3WCFJ1bK4UibcY7ZUf55gWU1haqMYo qiwkoJbGBblUPGQDzZP3diH34I2KRpE9hulLKB9hcqFwXYEsmaGWNegMRAGjKf4lDjWCBf iFfXcbRXqhqwX/iXUaC/uJgI3mOERFQ= Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5dc20645871so993093a12.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=kvack.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=IfmHIA6sOcm6Pq3pkQ/hciXdagHKH5aKF1+CAGETYlxhBc1QT6kr5j5qUDHPylh/DS lGQHtiIOig5EwVMJ6+tTUn+E7YBj96LYt20p8qpdcjAmLgqgAYpbYFMa1n5ooxqTlC9E dmcAONMeqjJXk1cNMGldRfk9d7jyNazyFp4FR4mDJNfLfk31l9PPhxzt9K42SDOIqLBx MnDfsqzMzeJhL81mg61TozrosmPc0PLwpHIpmaxPDMZAPiVF9pZ7QrYQ7zSVVlAWgSG0 NPdlkcWQ53MC4kX637CNmj1zFmwVe2bFDYk6Zc1wVEiO8q25UyXCYiUmIf3QrNOwrure KLaA== 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=UviyGlS9y7VlhallC76BGNaFo5XGNyRxagG4GPg0lIYKOuaSRU/5gk1iR0XSnHbs0E 4fk36rMcrbnlMILz5DpeQ/nTzNtz8NU9H/RXGycLShg0V49eBenHlALnWXHEm1y3YbTe NgxzSp2JlxtVs5tIoAPra2ivjT40sHlnZkEyBAzwPXuZpIwL3+bvC9CvVe5+alxJmtYC KuWMtSs6fXBFcoAsTEaUcc4t7INLb4n09GA/zLCp7bGP6s3uYchCPIhkuuV3wqhm82D1 kA66iOfoY8FjCHjU64iYwezELy3edRtSRqWkbjxx8kxzSAAv/pib0DJEtiuqgHcABh1b ZmWA== X-Forwarded-Encrypted: i=1; AJvYcCXOf2TcBz8M+ITJ9EDEoH+HXK2o5ZlTdPRIZ16B+agReBzkhOTHmw7FNjoLwmi7HChsSzEBa3H1G6N0TwKmQnBWnW0= X-Gm-Message-State: AOJu0YzzPqDWROyEViwO9F++ynzvQFWZdtqOM2yW2kkI0kUJbUsV9Mx3 P1rO1R09IQjsVZ0g+MexWaWMPUGNcNl5FL++or0Xagb1pi55Ti/44FeBIBKb6bA= 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240215154059.2863126-1-ryan.roberts@arm.com> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 09238C001E X-Stat-Signature: 5czp4zmhyqe6njwnbgzmeqwotanc8roo X-HE-Tag: 1708041844-402776 X-HE-Meta: U2FsdGVkX1+DEM7KHAXnWR0LwkOtgXuj6pdO6+cP4cP+29nMK/3Dtr5yVJZFDz7/NpuxPtiG0RjElzhG9K6pM5nS28ZymCnqbj8srIKDxZdScHXTcVx1YPPmdne0GOWANGxW1TW8VWVKt5MtEOEcZoffKQ7921ZwZmkN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1q+UohWmOSjJX2ZHLDo2lbOT4S4yNisEmFdGeZPbmnAM2dXqOZFvGmQ6M7TjF0LaMR4/yxQvyG9OSa9xJ/3bcIHVhhBSw0yLRU+/hMXJvg+Prjb8EVOD9QWofkffyevhYKyRjs/LDjrsihePyTEn+kGm0KUuJ8ghnOnGNUcpIiV6vUe5aJ++pXqhIpaiuoAy2/Y+7+09Q1OA0/5oCdFeYyYIlKyvnWgZhh2WgHz0OmP3rLDtOTukUqxAlmZFKwB70ipxenX0nRFD1cGJmy+h9Ow/eNTXG8c4sOAQpJcBO8vG0QTNnHHMED92AuYJyzmu 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: List-Subscribe: List-Unsubscribe: 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