From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.177]) (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 649603AB286 for ; Mon, 6 Jul 2026 16:05:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783353954; cv=none; b=Jrw61cILADDSc1KwJcgfn0NCNQhb7ELZmMLSTaor6bTql3rJQWp2ptohIPAc2c8n0QvZAeuuXZAE47ls3S73FHx2M/OthuyErt1G+UBtuq0CWHmv69vnIXBY6kN/pRtnF6S3Xc3M/fuZA5GIowt8akworHP0YMiQQA/3WU8yofQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783353954; c=relaxed/simple; bh=qWe53X1lFC1ssUPxFQ12xn2Gk79QM4DqyQFirq4yWnE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fvhcqEBp29nqJkPbx+HezPrnbhiLdsLHK524x0S0fFzULQdSTF3ca0DQ68d+/CeYDLV8NrfLixUqCftaDIaH2z1QQKx0myvsyEGQ9mO2VEORc0RfGNfu87K20pj+Qqw1C69+tEMKR5f7ZYYDlnthUgGjqPy9ey2toD4ul/i2ZuY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hammerspace.com; spf=pass smtp.mailfrom=hammerspace.com; dkim=pass (2048-bit key) header.d=hammerspace.com header.i=@hammerspace.com header.b=E8vwcT7j; arc=none smtp.client-ip=209.85.221.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hammerspace.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hammerspace.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hammerspace.com header.i=@hammerspace.com header.b="E8vwcT7j" Received: by mail-vk1-f177.google.com with SMTP id 71dfb90a1353d-5bef75a82d1so97044e0c.3 for ; Mon, 06 Jul 2026 09:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1783353951; x=1783958751; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=a4hRh2dxYEdxH4xJe+DcNxPcIhIgd93vbgkGk1FadTA=; b=E8vwcT7jqRCxEA23attoPfCtuiSqrdRs5NaYYyQM2XutnhUPuF/eeQbkWyUkfKmJkg ny/6a4LxaYs+3+ie8tFxpiYJAg+sT/6/8JhEchPHZ0meAmz/3DP0/1Ifzg3sev2qYUQ0 CAmYETAUlHlg5w5qNN07mM0w05KEmOdc/HMN9lWQnym+S/usPJHVaipgtZFG1xhx3IiT fBFFcordoGjy89+i5/bvHqgmxFc0stl0y+bGVlDYeB1h4egYUPTtbu+u+hZYgoYAcQXw 6BmNc00ax0OWxM3n0GHxG8ZbVI2/r8lP1kKiNceNjpiRU+i8EngcmKVXslnFVdwV3xxx Foeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353951; x=1783958751; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=a4hRh2dxYEdxH4xJe+DcNxPcIhIgd93vbgkGk1FadTA=; b=nYLOiEtsC7L5Tkz2IziPsQv087QSvCwAVftXOeKHPRHzE4SVctwWyhBVSm0GPYsEA5 cTd5w0WA0XkAdx/99z/yzCp1JlisS4zPQgVmH7ZVTfGBDNfNbCjpYiRUDEebuH/UXNbF 7zq8gWr6F0fVCxI1P/79cBDIctvfNV31CWw2fWsR6Rs6dFHU/+ZCV9/AKQCmSQs23qh7 qZTr5cFHvt/3GLuktu14pSLGlyq123hZpgSLTf14csWUUbtv2AGzpI0MeU3GkCQNCcn/ KkoYCRU2Mln/s53L4E6eCsU4Sv2HTi1ZaOVVNPEiuaF+ad21vWHFMiB1VAAbUwdfyHx3 OqLA== X-Forwarded-Encrypted: i=1; AHgh+Rrz4wx3su5/LhU98NCmn1hXe/kzhpT5UV/yWD0jyKpEVDeKiqmZt2uKH7GrTRiqt5hYJLw46osPLYLIaoo=@vger.kernel.org X-Gm-Message-State: AOJu0YzEGHJ1mDI9HAgM3VIsVoH8Qi3qXTiwv1/m17LYrBYVbvzAzQXz 0fGJdsdu2z5jEjaZdMuGZAUoTgV0lv91ONPQ8tlteGKS/zfhQb7+s8nGeGhkT9rsu6o= X-Gm-Gg: AfdE7clHAXP992dUK/m4A9AkG4lH/A+Z7set/JniO3sH6M/2C2BSUxhTNbIOCuI2L0K cfwrhlubZTGAGlMErgN2HIJjn14wbPBFHQ0CliMEW8Ew0JO2itRxFhgRYNMXsGbo5cIBwkO7jjn IMlDgpUBetE2nrIL3FKWDY8TfH4JxqtWBfZtGbWVNLJ2yIaQCRaxvyIESwSYhLAdBHkcQK8TaYb nym0Db42VbExLUB6+oHzt/m759/MLGL16+NEB+XC5YSbeL8F6ubn1IvGLGx2Ci8O34ZKKovnR+0 MuS3+z9d6BMwvqlunhsPDkFT1xpLfwH4sxq8txPJ+9tuUDy/OtfFCgQKJzk1uAzDbYV/VwowAdS 0liib52I8aMwA2YBhEJMWlsE7Y16vqb+GEJjueazOECKJAMse3H4uXkyTmwoPZcCkK96kHL1Db1 0rJea9ibdfH6f50i/FVn05rlJJwZ3Za9bCgrZCu4ol17/Kr4wwqbZO0WsfCRH8skBWhs+L9z23P n5Q6xJ6XmHasQiR X-Received: by 2002:a05:6122:6e0f:b0:5bd:71b1:d5c6 with SMTP id 71dfb90a1353d-5be9071c985mr664909e0c.4.1783353950982; Mon, 06 Jul 2026 09:05:50 -0700 (PDT) Received: from localhost (pool-68-160-167-46.bstnma.fios.verizon.net. [68.160.167.46]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92e90b804c1sm969257585a.5.2026.07.06.09.05.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 09:05:50 -0700 (PDT) Sender: Mike Snitzer From: Mike Snitzer X-Google-Original-From: Mike Snitzer To: Trond Myklebust , Anna Schumaker Cc: Tejun Heo , Lai Jiangshan , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] NFS/localio: issue IO inline when not reclaiming memory Date: Mon, 6 Jul 2026 12:05:46 -0400 Message-ID: <20260706160549.97580-1-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, Every NFS LOCALIO read, write and commit is currently issued indirectly: it is queued onto the dedicated !WQ_MEM_RECLAIM nfslocaliod_workqueue rather than being submitted to the underlying filesystem in the calling context. That intermediate hop was introduced by commit b9f5dd57f4a5 ("nfs/localio: use dedicated workqueues for filesystem read and write") because: LOCALIO submits IO directly into a stacked local filesystem (e.g. XFS) which may in turn flush its own !WQ_MEM_RECLAIM workqueue. Doing so from a WQ_MEM_RECLAIM worker -- most importantly writeback's wb_workfn running on bdi_wq -- or from an explicit PF_MEMALLOC reclaim task trips check_flush_dependency() and risks a forward-progress deadlock. However, that hazard only exists when the submitting context is itself a memory-reclaim context. For ordinary application/task submission -- e.g. O_DIRECT, or an fsync-driven commit -- the workqueue hop buys nothing: it just adds a context switch and scheduling latency per IO and throws away the NFS client's inherent application-context parallelism. This series makes the hop conditional. It adds a small workqueue-core helper, current_is_workqueue_mem_reclaim(), that reports whether %current is a WQ_MEM_RECLAIM worker using exactly the predicate check_flush_dependency() warns on. LOCALIO uses it (together with the existing PF_MEMALLOC test) in a new nfs_local_defer_io() helper to decide per-IO whether it must defer to nfslocaliod_workqueue or may issue the IO inline. Reclaim contexts still defer and are unaffected; everything else runs inline. Patch 1 adds current_is_workqueue_mem_reclaim() and applies the gating to the read and write paths. Patch 2 removes never-taken FLUSH_SYNC handling from nfs_local_commit() (every caller supplies a FLUSH_SYNC-stripped "how"), which also drops the sole user of the ctx->done completion plumbing and the now-unused "how" argument. No functional change. Patch 3 extends the same gating to the commit (fsync) path. Note the writeback-triggered commit does reach here in reclaim context -- nfs_write_inode() (the ->write_inode super_op) runs under wb_workfn on the WQ_MEM_RECLAIM bdi_wq -- so that case correctly keeps deferring; only app-context commits run inline. Patch 1 touches the workqueue core (kernel/workqueue.c, include/linux/ workqueue.h), hence the Cc to Tejun Heo, Lai Jiangshan and LKML. The new export mirrors the existing current_is_workqueue_rescuer()/current_work() context-introspection helpers. Additional note for reviewers: - The inline path now stacks the NFS pgio path plus the underlying filesystem's ->write_iter/->read_iter (and vfs_fsync_range) in task context. The reclaim-context stack-depth concern of b9f5dd57f4a5 (2) is avoided for the deferred paths; feedback on inline stack headroom under deeply-stacking filesystems (XFS especially) is welcome. All review appreciated, thanks. Mike Mike Snitzer (3): NFS/localio: issue IO inline when not in a memory-reclaim context NFS/localio: remove dead FLUSH_SYNC handling from nfs_local_commit NFS/localio: issue commit inline when not in a memory-reclaim context fs/nfs/internal.h | 4 +-- fs/nfs/localio.c | 56 ++++++++++++++++++++++++++++++--------- fs/nfs/write.c | 2 +- include/linux/workqueue.h | 1 + kernel/workqueue.c | 24 +++++++++++++++++ 5 files changed, 71 insertions(+), 16 deletions(-) -- 2.44.0