From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B97C64DBD62 for ; Wed, 13 May 2026 17:38:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778693920; cv=none; b=HKUPPEScJiZYaesdzolb9wUGdk+AwOgzhDxboFU9rbZTPMFOL/kitnLwAfSJjZSwyyHPFgQGhec0enlXmCKbFaEm5cqKyUsqAt/F2Q5LXeZiPt6YTmHH6CNt1ehynjv2HJZuVs4SZTd0RExv00tNygzykWo/63zIt4sblnD0iOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778693920; c=relaxed/simple; bh=N6K4B1CTT6yPfuEBOvcCzB3o4HYWvogfL8BuiuQ+vKA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PpWRkHF5dknQaILE+m/o5nk0E5yZS4f+14nAdC9mCg+84jc42MwnLJSHOpg9AR23Za0ku69IM6s/pVa7sD1CKTKk72wAFMPSpLFcG/SLoo9j5fjmhZY/5i5FVkkNHz8XJuEkEkHSPm/wuRzA9rQEvpHHDvxcoEqUfNJKYUJbQ/4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=siVcQ0n0; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="siVcQ0n0" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2ba3b9bcf69so875ad.0 for ; Wed, 13 May 2026 10:38:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778693919; x=1779298719; darn=vger.kernel.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=xZHV2Kb6uwd0Z6ZEGhEeHOrazGmeyX5uyJYUBguLyzA=; b=siVcQ0n0QudGSRhoq4EGc05Nc4YHG5HfDpZnaWxUl25ajB1y37xQ+9EqhZXYqEX0Bk U8wDWqEbLM5R6R4UcUJADnCq8PB5V+GNsKbIee9iAqqG2upnv/k/VgPQBdMHV2YzTbwW wGxC3rDY60hQjkI8j4NBqWBbzRIVeIUP8xOE9vb7AgCTbTzllT7qUhdp76vE6ukrwrEu Nnz4y5bQiJI+hE1sReIBrIYIwu6GJf4h9AKhEVWGDKfWbZXcOIPj+/en7ZZzMnFXRPBZ aHiSS5I9cRHdR8m9mNktsVi4ekRClwM9cz3ytvPeZ9/e9rC42VgJ5E9zOlxin1cFgBFr BWrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778693919; x=1779298719; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xZHV2Kb6uwd0Z6ZEGhEeHOrazGmeyX5uyJYUBguLyzA=; b=deG4waq2FFndXKgeVdvdFqcuhZV1GeYrdC8pa8f+3yjCESD8q/G6dPcKQ68CmOZpYq p4PkniPodLry6ttI82SYatAqUNuxm9+bKzHrtxappUBRCru0IpfCv9Mwjto2iYJ5BQFW XL4q7aBbwc0oOI145dZF8hABf3eTezJyh4UshKs95nvrGkQ5XgjcVde78VZAxzcjkUtk wECioYZqcvpD2CYWWirMLwRssNZSmWUYpMIImcZGpaJJRdppPHhBFBCxwKf75bDQKLjk 1DugEs02A//DmXcMx4RkKifHmDMhb1fxbZ+9ff4yCnwkLTa2sCRCISjqqD5TFQmAMFOP Ns/w== X-Forwarded-Encrypted: i=1; AFNElJ8OIxoiRyRLiVaczZO5RrrSMEowlP1m5F9rLqjSD+Req7EEj0l2kPSR1Vqu9mNZ2wC93pzeqtyxV29OpkQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwEpXBlvRnrREmv5H79HQYFYgwDnxLJrEIUu9Cp5WiXYVRtgDup 8Oh9giWnSaeal6FkhScJPeZpb/THKgE9vwrCdXWl+Rs8VJVO4GgGClc0n8bKbaiLIWxF3Fg9NNz ua1pirQ== X-Gm-Gg: Acq92OH2PdwsZWGg+tPnrcX7tvMnSXkLwYJ+G7BPcCyAB466KIHbIYFYyZm6UA2Q2ka t5jJ2W2/T35Sf370jY3HN4r5a6AJZloPV1xpXpSn9+jAP1OZmgp1PZTeZu/hk/dkf+WG3y4IO36 Gwe3kI8IR3H6wCAIgam64CIDiIaugOEw44jGcQJa+MXfPJO9XjjjwSti/J/ZkgWhPoFiRmSDl1a SG5aeXpnUD4p8q00ggBys2IpaPNceFHMh9ZXKuahXhFWSKYSxHLmb/+uBEEXP2ZHrw2czUSBYFX b0o4iTfvjBvsKxRH6y0uUhq/9tffBeTQqUdK8tVfqX6YrDd+dj8o+woQjXPzw4oV6XpJgs4796s IvfAlydiGm/mURmVCcHrrBGguFXukiPnG7N7dXWPYd8ePWFKeBoT2ELVkKlZczF6chjd8fwUfMg tVyyxEtypAZY8zioKT7fICVxOf4V0qMpyDMQhxWc8zoXzlnC0fpNzFwOlgvpWS8Xc9tWcugFlRK UeSmjY= X-Received: by 2002:a17:902:c401:b0:2bc:a58c:fd7a with SMTP id d9443c01a7336-2bd55e48463mr183585ad.16.1778693918255; Wed, 13 May 2026 10:38:38 -0700 (PDT) Received: from google.com (44.234.124.34.bc.googleusercontent.com. [34.124.234.44]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e6199csm223692405ad.55.2026.05.13.10.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2026 10:38:37 -0700 (PDT) Date: Wed, 13 May 2026 17:38:31 +0000 From: Pranjal Shrivastava To: Jason Gunthorpe Cc: Will Deacon , Nicolin Chen , Robin Murphy , Joerg Roedel , Jean-Philippe Brucker , Catalin Marinas , =?utf-8?Q?Miko=C5=82aj?= Lenczewski , linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iommu/arm-smmu-v3-sva: Enable Hardware Access and Hardware Dirty bits Message-ID: References: <20260508123550.GB9254@nvidia.com> <4e129891-2f52-4bac-8e33-1fdde42fd29a@arm.com> <20260513143213.GA787748@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260513143213.GA787748@nvidia.com> On Wed, May 13, 2026 at 11:32:13AM -0300, Jason Gunthorpe wrote: > On Wed, May 13, 2026 at 02:27:48PM +0000, Pranjal Shrivastava wrote: > > > Now, if we're work on an SVA page, with only SMMU supporting HTTU. A DMA > > writes to the page and the process (CPU) calls fsync(). IIUC, it performs > > a lookup in the Page Cache specifically for folios tagged as DIRTY. > > Since, vmscan didn't run yet, this could potentally drop the writes.. > > How does it work differently in the MM when the CPU has BBM support? Hmm... I looked at fsync and I see that it eventually calls folio_mkclean() (via writeback [1]), which performs an rmap_walk() [2] to harvest dirty bits from PTEs into the respective struct folios. Similarly, the vm_scan path does the same thing via try_to_unmap [3]. Since the MM subsystem actively scans the tables during writeback, it doesn't matter if the dirty bits were flipped asynchronously by HW (w/o kernel traps). I guess that settles it, we don't need to gate this behind cpu_has_hw_af() and we need not care about the CONFIG_ARM64_HW_AFDBM either. Reviewed by: Pranjal Shrivastava Thanks, Praan [1] https://elixir.bootlin.com/linux/v7.1-rc3/source/mm/page-writeback.c#L2905 [2] https://elixir.bootlin.com/linux/v7.1-rc3/source/mm/rmap.c#L1103 [3] https://elixir.bootlin.com/linux/v7.1-rc3/source/mm/rmap.c#L2164