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 2C6A2C47DB3 for ; Mon, 29 Jan 2024 22:46:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC43D6B00AC; Mon, 29 Jan 2024 17:46:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B73D46B00AD; Mon, 29 Jan 2024 17:46:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9ED9D6B00AE; Mon, 29 Jan 2024 17:46:57 -0500 (EST) 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 9065F6B00AC for ; Mon, 29 Jan 2024 17:46:57 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 59ADF1A02EA for ; Mon, 29 Jan 2024 22:46:57 +0000 (UTC) X-FDA: 81733835274.04.F898EE5 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf01.hostedemail.com (Postfix) with ESMTP id 5E5D940010 for ; Mon, 29 Jan 2024 22:46:55 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of msnitzer@redhat.com designates 209.85.160.179 as permitted sender) smtp.mailfrom=msnitzer@redhat.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706568415; 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; bh=4Y1TC6ozjJZpDR660NrUM2DmjgjZssr5RPk8k265VkY=; b=oGFfqJgvEuS1K8V35KJ9sFeANBhWnlqAYxsRHuMeonZDfj12++DzCnQPAM9ZqFbnmgHvJJ F7qu9nMg/ZYDIxBiMdIcIt/mgd6jdh04nIUrbv+TEfuObEDzI9FyAwPqCNQe0hVZ6qkB0v wUJeEYdzC5vzWmcM9V8pHSikDzb0FCU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706568415; a=rsa-sha256; cv=none; b=R9SaQTaA1UeBdYizqMjY2U5kNornGXNJzsNhfrNARy+o09FCOd8zNgQ63Ysh2ErLBHDu4X D7pcGcvWkVA0XtZQJA3O26OAjbl50lndHo73o014J0/0W6/HVjtwjNUEsV78bj8kGFgFMJ pfcXaMxe3tsTFdVzaMs7WaY4zuIaPxg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of msnitzer@redhat.com designates 209.85.160.179 as permitted sender) smtp.mailfrom=msnitzer@redhat.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-429de32dad9so29616521cf.2 for ; Mon, 29 Jan 2024 14:46:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706568414; x=1707173214; 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=4Y1TC6ozjJZpDR660NrUM2DmjgjZssr5RPk8k265VkY=; b=EKrSnc2QBWadNzoeYT+HRlGedacE7ERc+GyHabrFnT3o/QQ8LC6Bex/pG+5zJaOLr6 9phkojjKwUfS17wHC4o83fdFhDoE2bUtZQW2QhXhuY/ezAaeX3A9rJS8J2STC+AS92Qv spyxTilOtN2vheJ926pc/lhzZR7Y2OFs5LG+f5q6/dRTxURpw/1KYgxerQWUL21o5qsQ 3KxL54JylE2ZJ0hus6PlUAURrMNNwPOEJGd/84hq7d7pzAqEgzI58d0ibP1H9f0SkyB5 QeCf3MvKVatJFWo3SNS9btFoGUrIu4YWTwM+97evdGeWvlgY9VkskUKnHCBPtjs6Xjbu bbCA== X-Gm-Message-State: AOJu0Yx+/zFQWcgWZq2C7NkLFeHU5SX4l+hf3KsfzoE4+JZuzm0wpc6b 20LyhMgXBAHOT8iRBoN23DFWPx6wplNqS3B27Ji49dkEsccoR7ucdsDZrY+7eg== X-Google-Smtp-Source: AGHT+IE6sdw2UMPyjdmSHO2Q/aOZ/VKQc/wBLWuOWcfTwiePWMJWreri2G4nKR0FgOPeREPo2MLweQ== X-Received: by 2002:ac8:7c4d:0:b0:42a:b4c2:e71d with SMTP id o13-20020ac87c4d000000b0042ab4c2e71dmr293866qtv.70.1706568414455; Mon, 29 Jan 2024 14:46:54 -0800 (PST) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id bc6-20020a05622a1cc600b00427f1fa87e6sm2079280qtb.56.2024.01.29.14.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 14:46:54 -0800 (PST) Date: Mon, 29 Jan 2024 17:46:52 -0500 From: Mike Snitzer To: Dave Chinner Cc: Ming Lei , Matthew Wilcox , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Don Dutile , Raghavendra K T , Alexander Viro , Christian Brauner , linux-block@vger.kernel.org, David Hildenbrand Subject: Re: [RFC PATCH] mm/readahead: readahead aggressively if read drops in willneed range Message-ID: References: <20240128142522.1524741-1-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: oasbmh3q474dmq8arebp5dbub3pes5zf X-Rspamd-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LVNKMB4p1Kxyar85MUrIzXR1aMZq3lJqgG30MF5l5LDnkQHtZ56Dd6iT0QEUL37Tsag7K2FG83nZfNhaWDE/JiNaQ/S2ai+xqq5y4BoEi2O0HkwHvrMo1L5MvRjp0dZZHVOj+YxlcjGEg0byM3UiCU/dr9Ln3l2IDwBOGkD3sbltJtAAagSeviAeibnfhSTFAb1Cp7w6dGG176c3hkIhTzkJlWqGPODikptoK7SYq7Af3kM0PJ16ufksuursqzsaScm3iZz73KmS2eKqNSIbNS6KIYEkA0CUD4Y+IomJHJ509ZnqFwTKPpqQjZ0Gn/gPxTg10MQH/LXVtz0fGgvEJClXdY8SpGCxXZSpprdfMOrO7GnhW0Hb4vAJIs0KUsJix8VLkWaAcYT1JL+jDiLrdb7Fs0JGbNtZfhJt0pM8j6UQqQccruRQWMNcXUZVBKz6AOPNtkPkOGxICo7jcFcVs28FMZtz2wMydRYfc0JRTD3Bpnq4r8ElgcOkre4Nx5xDEn1LmalXy3Zdy5M/xnt221VN1mS3zdwt8oOPBH+meGdFDrCNPDDta/lRFjuyBBMuH40I/E811gEbWdkvQ== 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 Mon, Jan 29 2024 at 5:12P -0500, Dave Chinner wrote: > On Mon, Jan 29, 2024 at 12:19:02PM -0500, Mike Snitzer wrote: > > While I'm sure this legacy application would love to not have to > > change its code at all, I think we can all agree that we need to just > > focus on how best to advise applications that have mixed workloads > > accomplish efficient mmap+read of both sequential and random. > > > > To that end, I heard Dave clearly suggest 2 things: > > > > 1) update MADV/FADV_SEQUENTIAL to set file->f_ra.ra_pages to > > bdi->io_pages, not bdi->ra_pages * 2 > > > > 2) Have the application first issue MADV_SEQUENTIAL to convey that for > > the following MADV_WILLNEED is for sequential file load (so it is > > desirable to use larger ra_pages) > > > > This overrides the default of bdi->ra_pages and _should_ provide the > > required per-file duality of control for readahead, correct? > > I just discovered MADV_POPULATE_READ - see my reply to Ming > up-thread about that. The applicaiton should use that instead of > MADV_WILLNEED because it gives cache population guarantees that > WILLNEED doesn't. Then we can look at optimising the performance of > MADV_POPULATE_READ (if needed) as there is constrained scope we can > optimise within in ways that we cannot do with WILLNEED. Nice find! Given commit 4ca9b3859dac ("mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault page tables"), I've cc'd David Hildenbrand just so he's in the loop. FYI, I proactively raised feedback and questions to the reporter of this issue: CONTEXT: madvise(WILLNEED) doesn't convey the nature of the access, sequential vs random, just the range that may be accessed. Q1: Is your application's sequential vs random (or smaller sequential) access split on a per-file basis? Or is the same file accessed both sequentially and randomly? A1: The same files can be accessed either randomly or sequentially, depending on certain access patterns and optimizing logic. Q2: Can the application be changed to use madvise() MADV_SEQUENTIAL and MADV_RANDOM to indicate its access pattern? A2: No, the application is a Java application. Java does not expose MADVISE API directly. Our application uses Java NIO API via MappedByteBuffer.load() (https://docs.oracle.com/javase/8/docs/api/java/nio/MappedByteBuffer.html#load--) that calls MADVISE_WILLNEED at the low level. There is no way for us to switch this behavior, but we take advantage of this behavior to optimize large file sequential I/O with great success. So it's looking like it'll be hard to help this reporter avoid changes... but that's not upstream's problem! Mike