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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9BF9C4363A for ; Tue, 20 Oct 2020 19:05:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D6C8E22247 for ; Tue, 20 Oct 2020 19:05:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="vkYyuanU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6C8E22247 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DED616B005C; Tue, 20 Oct 2020 15:05:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9F706B0062; Tue, 20 Oct 2020 15:05:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8CBD6B0068; Tue, 20 Oct 2020 15:05:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 99F7E6B005C for ; Tue, 20 Oct 2020 15:05:22 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 322D68287DFA for ; Tue, 20 Oct 2020 19:05:22 +0000 (UTC) X-FDA: 77393232084.21.straw76_0e143a527242 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 0DE00180442C2 for ; Tue, 20 Oct 2020 19:05:22 +0000 (UTC) X-HE-Tag: straw76_0e143a527242 X-Filterd-Recvd-Size: 4306 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 19:05:21 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id 188so2640586qkk.12 for ; Tue, 20 Oct 2020 12:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=i0ZCk7XG2PtOYo9dUxzaqtMjHhevbcaYlf08O9nVmXk=; b=vkYyuanUObY8WM3gyrIp/sCVPZ5tzz/eYiQmGjnmhefUJPKKKi/W/2TVuMu8FeraYw yMlPHfWjiwaWjjwdpOSEcJ1sYPPzuZM1vz/QUWdCU3ZbeWLsa5K77ttPVQ1ZMQt2V/md W6od2dJovrdJ2ReDtaeYlp1UqSlBg1IR/DUdQLNIQrB5ZJ7M6qrywELioa1I+1V87FCK XnPx1bww5mfowZuMNWY2U3Qx7elC+Fhnt/bvCk6lmkkWf5UiPb6lYLn6hINmJCcnThHr 9fZezlcxs97Qx2zEgMUurrJZjGkYglcXjDG6mkiQbvbfWH3gMJyQQ8qRINuErVGdk8aL 5o3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=i0ZCk7XG2PtOYo9dUxzaqtMjHhevbcaYlf08O9nVmXk=; b=QV1LMzxHsEIE3xtmRZhCJugfMhmnyqOAvQbpYmOoELiiW516vD0QWkbMLIs8szl+13 e2vD+o8iQ2/08MP0pWUpUguoj2NUS8t8K9xxPh7qEbALpb7a6NUL+E5zf9bi4TzEbx+O cvLTMpRKhN23x91csrs0zrJ8YyUYkfH64Wh6eGEKUx+SWrTk6Z4hs4nAc79UnBJnDp/D qK6PItZLPci0bcxCRfwx4t2cU5vHro7zlrnxbWGStXvHPqfJhno24Rs+wt3VJ17n5EXK a9dzzmhPbUkHKCUDncJNzb/3ihZRaOCU1GjuYk4z9N000rl07zpzl6aDmGJNwwmSv53e J8mw== X-Gm-Message-State: AOAM532sQxycxPjArdZ/YSwUVb23YG+uuOU+R/hn1Es3nASJVGYVfXfL c3J9lHS+tRpEjQQR2ZxX1v4PLALuyvmHnw== X-Google-Smtp-Source: ABdhPJyHgwjegFMAsXjeBxd0q/8I3QqAjTOoAjWCOFQTpg9i406S5W+TLwvd3QPyuTWMJJWDoSj2hw== X-Received: by 2002:a05:620a:893:: with SMTP id b19mr4106617qka.111.1603220720716; Tue, 20 Oct 2020 12:05:20 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:c52c]) by smtp.gmail.com with ESMTPSA id y94sm1185728qtd.7.2020.10.20.12.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 12:05:20 -0700 (PDT) Date: Tue, 20 Oct 2020 15:03:43 -0400 From: Johannes Weiner To: Jens Axboe Cc: linux-mm , Andrew Morton , Kent Overstreet , Matthew Wilcox Subject: Re: [PATCH v3] mm: mark async iocb read as NOWAIT once some data has been, copied Message-ID: <20201020190343.GA398685@cmpxchg.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Oct 17, 2020 at 02:07:26PM -0600, Jens Axboe wrote: > Once we've copied some data for an iocb that is marked with IOCB_WAITQ, > we should no longer attempt to async lock a new page. It could be useful to elaborate on the (user-visible) failure scenario here a bit, as I don't think it's obvious. > Instead make sure we return the copied amount, and let the caller > retry, instead of returning -EIOCBQUEUED for a new page. We *wouldn't* return -EIOCBQUEUED, though, would we? We'd do the async path, put the caller on a waitqueue, but then return `written' instead of letting it know. > @@ -2199,6 +2199,14 @@ ssize_t generic_file_buffered_read(struct kiocb *iocb, > last_index = (*ppos + iter->count + PAGE_SIZE-1) >> PAGE_SHIFT; > offset = *ppos & ~PAGE_MASK; > > + /* > + * If we've already successfully copied some data, then we > + * can no longer safely return -EIOCBQUEUED. Hence mark > + * an async read NOWAIT at that point. > + */ > + if (written && (iocb->ki_flags & IOCB_WAITQ)) > + iocb->ki_flags |= IOCB_NOWAIT; That looks correct to me, FWIW. It took a second to verify with all spaghetti in this function :-) But the ra/!uptodate path already has its own guard, and this is needed for the readpage fallback.