From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 977BA3F54A2 for ; Fri, 1 May 2026 16:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777653863; cv=none; b=eJ2a3AuUG4m+kUH2CoZ2m3a/iUDZw29BnKh+3VGkt23RvzV0m4XDVJqrMbmgSXGkZQSkw3DQyyepFF0Tl9svRknBE8rlDsUgf+jyiJiJMQ1jTjOJiGZ5C1jFn0KZKzalN7tWRo/rZJ7hvC7MGiDAhhnQqW4fYvgAx7SXiCrbdT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777653863; c=relaxed/simple; bh=BzpvNNe0Y7pWnImNb7utvKGVhDIu4ekSHRzW3u8hMCQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aL/CQUqxRZfl25n2gvw3FkPj/1pY65q4CjtZPtVmldili1SlqkhAgp9M3ZyirKP4bJP+58FPe0DQ+QLsw85tbSBaUY98+agQAGEuSoywracLauI8V3x8K5qRH9AjHup+C54b+1ZaCYm2riA42fA0vrx1gbSemub0shSLS7N2D+E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20251104.gappssmtp.com header.i=@kernel-dk.20251104.gappssmtp.com header.b=t/A09e1g; arc=none smtp.client-ip=209.85.161.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20251104.gappssmtp.com header.i=@kernel-dk.20251104.gappssmtp.com header.b="t/A09e1g" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-6948fb494a0so1199825eaf.2 for ; Fri, 01 May 2026 09:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20251104.gappssmtp.com; s=20251104; t=1777653854; x=1778258654; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=258tSgDmQvsBwqYiudf3HzA2YcVV3/7qcjtUVSy9L94=; b=t/A09e1gBKwHej8bFSSsDKaY+HbwtWehYTY6lD/aQAbC6dd7DgC01GYCseKf6U4Drp Nbu7cxnKVoOHHYDRK0bMNqX38VmWz9bPLe7lXQjWZhwP8rQ+wBdaOc2TZfNjdTp+fq5n J4/yDwZY6l2DpYYyZBBrSJ/aqLOZvzOcbRlBtgtIyA+Ug2IyK8NITuZt1WnAr9tHJZU2 2aNDB1xK/1sP9de7FFVxjaqR2bVfBbc7w3XUCpg2PuqK+E7TP8Awfn3yzKbmJMP3uTaR dqBtWdMDAUQ8PtDgW0rUmoblNP27wev8sG/a2YqsNsQVbkvVAj+TjSvxxHE4pKcUrX8K v6gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777653854; x=1778258654; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=258tSgDmQvsBwqYiudf3HzA2YcVV3/7qcjtUVSy9L94=; b=m3ImzXZ+3MnFzdn499zi5W/BT1uEVBHFSnVuk2FdxhYwIXx2uUIPXy5CECbBlQbZbZ NlZqXyAuMw+qtvIjqBlKQR+DmYDTnT6JKjWH9C0sFf8bzPDJN4OVK6XCn/mSLhK+yZmq Tt1p0zDvlaryfTDyTZuvw/0OJCMzJYCGs3kInb0Og1YNv7x8BF7+Se9B1Lx1y18Q50jZ GFBBzF4ryzSP4McY4FKcXcuazy9NeiCzZzyuHw+XumwzEBILABkskFhmPRA/LReeaWit drBueJtJhcySxf6pMDbvQpa4qVM7LbWaGvfOhLp4L9/URGvaeGi47It5d2ltKmgph37E 3rOA== X-Forwarded-Encrypted: i=1; AFNElJ+7KCMi12qJNei0zbkremdBbtGoUCug20sxitjhsG7RDMsRdd2lkyYjLYLLeMOvgWEWpoXK5xXtI/7HexY=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9mrpyq7JUCXFwBCGCc2LI+ppBmel92pU/H6DbGOkzoqurDCGp syAutXMXekQScrP5ToI7RtCVwONT8VoZE1jg0I9HuBdFKY9uATss5w8F5Iu8oRHdweU= X-Gm-Gg: AeBDietu9ddnyP5664lquSHRYmEJyHHcVfnfVA3bw3Em5olqyyUs5/3b7ZB4LCKO2+x PY0JgXoAOTdpAtOSL7uIQ1/2kysRpbsUdWZiF244sBtALyFXEnUPe/cVG1R9L9rgmDnOB7SFIu9 Hu68w46i5uucxunBzjWmbFKkyPHZvmH4ax5JDa/vm9dh5pC4+6XT5BHLG9qKMTpfcr4G4Wr80+5 KY7J4tzSkMp43XIDEXu68uBiXT16r7OUY33qIcu7MoDzrgHUSSpADLhcc1JZK5hYxOfNtNWGkNk gbO27tqswV70IbF7fRXFndA0nuBJh8t5Ih33gfFbX1uquo+98/zm3Ghz1SfsFz206vMBzmBerpI plMr04+jcPvrLaQLjglBp5p4+NevTaJmr8ElB/L25WXSGW/gJjAwjfonJsAyT+TJeINluejNXV0 8X1R6MUYCU78W4Cq5+SMoUJ/unvY26H135ktBqCt+/hD49uMU1tFPsYMvJO0yMRdV+oDgyXPf8l Bo2Ql/4BZDkqunrXUM= X-Received: by 2002:a05:6820:a04:b0:694:8c67:5cb6 with SMTP id 006d021491bc7-6967a5dbd54mr3873019eaf.41.1777653853660; Fri, 01 May 2026 09:44:13 -0700 (PDT) Received: from [192.168.1.102] ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-43454d8ed0dsm2836466fac.17.2026.05.01.09.44.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 May 2026 09:44:13 -0700 (PDT) Message-ID: Date: Fri, 1 May 2026 10:44:11 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 2/4] mm: kick writeback flusher for IOCB_DONTCACHE with targeted dirty tracking To: Jeff Layton , Alexander Viro , Christian Brauner , Jan Kara , "Matthew Wilcox (Oracle)" , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Mike Snitzer , Ritesh Harjani , Chuck Lever Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org References: <20260501-dontcache-v4-0-5d5e6dc71cb3@kernel.org> <20260501-dontcache-v4-2-5d5e6dc71cb3@kernel.org> Content-Language: en-US From: Jens Axboe In-Reply-To: <20260501-dontcache-v4-2-5d5e6dc71cb3@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 5/1/26 3:49 AM, Jeff Layton wrote: > The IOCB_DONTCACHE writeback path in generic_write_sync() calls > filemap_flush_range() on every write, submitting writeback inline in > the writer's context. Perf lock contention profiling shows the > performance problem is not lock contention but the writeback submission > work itself — walking the page tree and submitting I/O blocks the writer > for milliseconds, inflating p99.9 latency from 23ms (buffered) to 93ms > (dontcache). > > Replace the inline filemap_flush_range() call with a flusher kick that > drains dirty pages in the background. This moves writeback submission > completely off the writer's hot path. > > To avoid flushing unrelated buffered dirty data, add a dedicated > WB_start_dontcache bit and wb_check_start_dontcache() handler that uses > the per-wb WB_DONTCACHE_DIRTY counter to determine how many pages to > write back. The flusher writes back that many pages from the oldest dirty > inodes (not restricted to dontcache-specific inodes). This helps > preserve I/O batching while limiting the scope of expedited writeback. > > Like WB_start_all, the WB_start_dontcache bit coalesces multiple > DONTCACHE writes into a single flusher wakeup without per-write > allocations. > > Also add WB_REASON_DONTCACHE as a new writeback reason for tracing > visibility, and target the correct cgroup writeback domain via > unlocked_inode_to_wb_begin(). > > dontcache-bench results (same host, T6F_SKL_1920GBF, 251 GiB RAM, > xfs on NVMe, fio io_uring): > > Buffered and direct I/O paths are unaffected by this patchset. All > improvements are confined to the dontcache path: > > Single-stream throughput (MB/s): > Before After Change > seq-write/dontcache 298 897 +201% > rand-write/dontcache 131 236 +80% > > Tail latency improvements (seq-write/dontcache): > p99: 135,266 us -> 23,986 us (-82%) > p99.9: 8,925,479 us -> 28,443 us (-99.7%) > > Multi-writer (4 jobs, sequential write): > Before After Change > dontcache aggregate (MB/s) 2,529 4,532 +79% > dontcache p99 (us) 8,553 1,002 -88% > dontcache p99.9 (us) 109,314 1,057 -99% > > Dontcache multi-writer throughput now matches buffered (4,532 vs > 4,616 MB/s). > > 32-file write (Axboe test): > Before After Change > dontcache aggregate (MB/s) 1,548 3,499 +126% > dontcache p99 (us) 10,170 602 -94% > Peak dirty pages (MB) 1,837 213 -88% > > Dontcache now reaches 81% of buffered throughput (was 35%). > > Competing writers (dontcache vs buffered, separate files): > Before After > buffered writer 868 433 MB/s > dontcache writer 415 433 MB/s > Aggregate 1,284 866 MB/s > > Previously the buffered writer starved the dontcache writer 2:1. > With per-bdi_writeback tracking, both writers now receive equal > bandwidth. The aggregate matches the buffered-vs-buffered baseline > (863 MB/s), indicating fair sharing regardless of I/O mode. > > The dontcache writer's p99.9 latency collapsed from 119 ms to > 33 ms (-73%), eliminating the severe periodic stalls seen in the > baseline. Both writers now share identical latency profiles, > matching the buffered-vs-buffered pattern. > > The per-bdi_writeback dirty tracking dramatically reduces peak dirty > pages in dontcache workloads, with the 32-file test dropping from > 1.8 GB to 213 MB. Dontcache sequential write throughput triples and > multi-writer throughput reaches parity with buffered I/O, with tail > latencies collapsing by 1-2 orders of magnitude. I like this, this is the better way to kick off the writeback. Reviewed-by: Jens Axboe -- Jens Axboe