Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp168051lqb; Thu, 23 May 2024 14:18:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4jfDUS1FceZ5goCZfzYpXPn8yVU1ZSLJMJS/5SSIiICZ8cGAwbLyOABOY2WPKWzRIemgFLC6fmwWY9HQ+bg6sPfK77KIPObBPFCEgPw== X-Google-Smtp-Source: AGHT+IEjcbT8amGivdxUiq6+XaLxFSaPLDa/+Y24dWPL/pxpd8OVsLbv7WTpUOAJxX5os+DhmGxt X-Received: by 2002:a17:90b:2311:b0:2bd:7629:e93d with SMTP id 98e67ed59e1d1-2bf5f711e31mr355267a91.36.1716499114539; Thu, 23 May 2024 14:18:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716499114; cv=pass; d=google.com; s=arc-20160816; b=iL+vPkBdgLekvwv19Uo0gZUTVvcvZVPEQPx3xXreBkeQTOm5VP7s/zOzetso+6YzXK 4U6CahBfDwTTb/75Xoctsb3hLrsA17kdnCank5MoCnTSY4pSgMs8zD/kyJtzY+dCU02N xxWqgNWPEW4S/cROfIlTHXB/GOC5YEjrWva3qA68L8iGgCY+1OWqFJKWQHjdfl9w4JWa daMvAD0WM/xH05mL/QzgCZBEsTraYcX5wnCyn3k0Zz+7S7CrhNjtJTwItMrtS1zbddXt a6S0zK6AMtGsvEuUygZNZivQ/R/1szKukIs6riHaOnMMvBqRDUEOrRgDUSATWd0STIYl pjbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=9x2cAYxI0ME8fv/6TArJaYakWUUv/hDKd/KCixzGcGs=; fh=16rg5Cvaeds5P5Nh5i7///L6GB3NXmH6cx0fJcb3k5c=; b=FMdgTy9IoDOfZYF/xm1mZxvsX00YEZkfCQps8xy8SmbpwKxVMKmd0tIVfMqYspEV6y B+UnxWH2oZeBEQ8DTgYbVFAH9SazElvSIsrBORCIyV7cRrTcnikZH9N1Sm8gl8PmNbmv HLqSMn9TPikN7h/cTEc6AsK/NjViNVMsrPED2oVa1VwO9uE0EIFAyExkDyypcBAxBACP ZiHJEcnWME9ba60xdAOrUJe3dFKYbn6zfsj/M4C1EKrooxK4dC/4HoY1FQbrMv69Ryvy rFFfxFLQehIYCj3IhJD1GxLHQIUmeflcarnIhpM88xQNPWxffAyhCwdXHcEDm91KrSRE 1gxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=1EJCUoFe; arc=pass (i=1 spf=pass spfdomain=kernel.dk dkim=pass dkdomain=kernel-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-188011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188011-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bdd9ef528asi2242472a91.73.2024.05.23.14.18.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 14:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=1EJCUoFe; arc=pass (i=1 spf=pass spfdomain=kernel.dk dkim=pass dkdomain=kernel-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-188011-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188011-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C5D90B224BD for ; Thu, 23 May 2024 21:18:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FD74127E24; Thu, 23 May 2024 21:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="1EJCUoFe" Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 C1B8543AA3 for ; Thu, 23 May 2024 21:18:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499082; cv=none; b=iKiB3OIa21XVSj9qpIfddQ0v2hQguN2tsy7KXnCGgjBfMJn2sgtSeoQj3MswkENBlDFiFFjK+5Pb2Un+pzLIQMXFA5WZIddzvdQBlAOqTexJINdg+WkASGuYTxHrH6hI21gyrD1rcLR0MosH8HPrL+DPjshF16peYzO4jReSOEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716499082; c=relaxed/simple; bh=E60KwS3yfBOzkwDT676+MM7o2Au2xZpAQhVcMH8quk8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iTxHsp8nCRTNyfDwDU/yzanneTO4yd/0fEf6hTnW4xgOce/rUz/Nb88IbCCVgbHGKJtD3lhOqEnTP8GbQ42e19iUO7w1OWbALeHS9Js1xp/nBrNyFB0vB7HmGidUx01+wo7xL7KaLF/YX26tlrmck+2hAo/qblTZgUyRsc8uB/s= 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.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=1EJCUoFe; arc=none smtp.client-ip=209.85.215.181 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 Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-6818d68f852so26073a12.0 for ; Thu, 23 May 2024 14:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1716499080; x=1717103880; 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=9x2cAYxI0ME8fv/6TArJaYakWUUv/hDKd/KCixzGcGs=; b=1EJCUoFean3bnHgKvXUnOX3TLVmm/BBxsxVr07pJaEDNZAzBuXKsLWDTR9Dz7rjiQ0 XdXHvjvFtYY59M+Mao2Ung4emgC/TxKH2EhTVSz0DbaPz7AvSmM+iACmIa5Y7fvlh8OY gzB7gV6nVu194iR8tSgfpglaZgv9K5jR+j5ykpigpLcjQepI/3XGK7nnkiOh/wXT5xde jJpRohJ+MkxGrdiih2Lm5yQROq7MwglZc81M8TVMd6yxpYD5TB0/0Pd1s/Iw7gBwlykn 7vGBVfO447ZHpZwox7YdSYB99lOecRMPbqphwPkOFakffaSICww344Ypf/1GgnRY16Hl Fd1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716499080; x=1717103880; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9x2cAYxI0ME8fv/6TArJaYakWUUv/hDKd/KCixzGcGs=; b=lSq52Wtg5Xy3S/vk7Aa6hxUnA+XVQOEjLw5GN/sEzuQD2fjecVgXgbxmAd2G+ZEJQg VNBrKmtZQ1g8UwuvYRdbjxkAJyX/ql0w6IdLVD6GWk3Wa0uOYWejTJZ2fPQcaubB/58e EJXyCwFrI4KbHV8LusdeKVeYy7j2R6mfakQc10ThglSIb0KF+N4oi2971DrVMYNaFAoX jdxGzaVR13jmjw0byAET+yJuiKqbhQXbMdK/DoAcXDpelg5+Kqmi/fD4oLfFIcrgspgS g58QTecIsU3QoSSVVsK2YyHgvqf57KWkbgxwo7hB0gRQvusHD9yLTE0FE3AWsrVPHun5 yYhw== X-Gm-Message-State: AOJu0Yyc6CWIRCoY9H+snSOPEvQHiFGE1zcmGyqnCD8JeFUAs/xV/Znk nvAC9Bmq6yWV2CajBrPfPvNc3uabvgQiJPiy1frrEWOVGsqrGQC6AjTFFmoiJdY= X-Received: by 2002:a17:902:e801:b0:1f2:fbc8:643c with SMTP id d9443c01a7336-1f448f2e808mr5711575ad.3.1716499079957; Thu, 23 May 2024 14:17:59 -0700 (PDT) Received: from ?IPV6:2620:10d:c085:21c1::1060? ([2620:10d:c090:400::5:32c6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f44c96f26bsm346775ad.127.2024.05.23.14.17.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 May 2024 14:17:59 -0700 (PDT) Message-ID: <359117d3-20e3-4c1b-a426-8ec1391ffec4@kernel.dk> Date: Thu, 23 May 2024 15:17:57 -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] mm/filemap: invalidating pages is still necessary when io with IOCB_NOWAIT To: Matthew Wilcox , Andrew Morton Cc: linux-kernel@vger.kernel.org, Goldwyn Rodrigues , Christoph Hellwig , Jan Kara , linux-fsdevel@vger.kernel.org References: <20240513132339.26269-1-liuwei09@cestc.cn> <20240523130802.730d2790b8e5f691871575c0@linux-foundation.org> Content-Language: en-US From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/23/24 3:11 PM, Matthew Wilcox wrote: > On Thu, May 23, 2024 at 01:08:02PM -0700, Andrew Morton wrote: >> On Mon, 13 May 2024 21:23:39 +0800 Liu Wei wrote: >> >>> After commit (6be96d3ad3 fs: return if direct I/O will trigger writeback), >>> when we issuing AIO with direct I/O and IOCB_NOWAIT on a block device, the >>> process context will not be blocked. >>> >>> However, if the device already has page cache in memory, EAGAIN will be >>> returned. And even when trying to reissue the AIO with direct I/O and >>> IOCB_NOWAIT again, we consistently receive EAGAIN. >>> >>> Maybe a better way to deal with it: filemap_fdatawrite_range dirty pages >>> with WB_SYNC_NONE flag, and invalidate_mapping_pages unmapped pages at >>> the same time. >> >> Can't userspace do this? If EAGAIN, sync the fd and retry the IO? > > I don't think that it can, because the pages will still be there, even > if now clean? I think the idea was to punt to a worker thread which > could sleep and retry without NOWAIT. But let's see what someone > involved in this patch has to say about the intent. Right, the idea is that if you get -EAGAIN, a non-blocking attempt wasn't possible. You'd need to retry from somewhere where you CAN block. Any issuer very much can do that, whether it's in-kernel or not. It'd be somewhat fragile to make assumptions on what can cause the -EAGAIN and try to rectify them, and then try again with IOCB_NOWAIT. -- Jens Axboe