Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4029947pxb; Tue, 19 Apr 2022 15:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXlUTHw/qQT1+xTIyIK9OQQyA/Pkt11tbyOVFOAU14QpjaFQBkcRn50davY6BWF8/c58av X-Received: by 2002:a17:906:640a:b0:6e8:643a:7646 with SMTP id d10-20020a170906640a00b006e8643a7646mr15587839ejm.751.1650406952977; Tue, 19 Apr 2022 15:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650406952; cv=none; d=google.com; s=arc-20160816; b=slGjbWzDoFEIjWeuvQ0DJCKZczdXsQ5QSl5IUZ+lFaKzAgfIFnvOeFC4yCotbOYaE7 p8KFvxD+GxoPMoI2aJBbIgqBc/E1uryPjqCmPkwE9upC6/5GTmGe40a+HBrG7djcEwd3 QwA9b+biCwGdDDxFiAJyxsCgoc4+YkVRm6MArHFFZXILw7xaUOau1uP2Kw6BnZkcK8EJ tcevt2rIPFR1vCTp2AtFdhu3lFi8VmDMu2YMObhFih6n9se+K/e7ZTjPtFVLWhtZypfs fMmeyIbT2y6VGjML7g7Dz4Snw629TCtCUikezSXAzV8HhMQvtVMT1bna3Pr+LBlQ4GZw 74Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=sWWX2GTsw+MtALKWmopT7j+jipc7W7igl5gIqNLQGM8=; b=Ix9LFEq5QT7fxlONxPjL0YJ2tQT+uw1fiNCFW2O/u9sI9kcW5gJcqp2ocBnVDCBtpB geLWZAia8QfEnrxVcJgyItshtJp1juo7IS3OtKRuUPtG2oWluHS1BV4y7/e4h9ObuTCc KZ8AHqn6kz/3BcaJqcQPqPDH7Mf/KdteR0KjGmyLlYwRD0Ez7i8GVEwlTao6d6r2R7TE VrPQ0wn8YdkhIdfx1OIdab4ANPGbQKYoEMcrI5ilwsKhp2LzyM8d9bHHgkPHCn2yGfw6 QYxxFpwJkCOJ6fAdgaPThZBsEKZw18WK25kdaJe7wMtw0NIC/1p4c/1wlUFE+qchkA79 fd8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=BX5jTyHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a1709064d8c00b006e880f531c5si359172eju.553.2022.04.19.15.22.06; Tue, 19 Apr 2022 15:22:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=BX5jTyHi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231162AbiDRWPb (ORCPT + 99 others); Mon, 18 Apr 2022 18:15:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbiDRWPa (ORCPT ); Mon, 18 Apr 2022 18:15:30 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE54427B3F for ; Mon, 18 Apr 2022 15:12:49 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id c23so13493425plo.0 for ; Mon, 18 Apr 2022 15:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=sWWX2GTsw+MtALKWmopT7j+jipc7W7igl5gIqNLQGM8=; b=BX5jTyHiYa5maCfpHH901AGhqCKQsy/+DQaDL94UEpRWnk8etBqCxBqNNWcBzGoXdJ gMu5lQWoN2whmbKR/G8jsoSV8FdAaM4RiGCicjbGBy9dG3DTr4wgtSsLU5NhLzQVDxzG xkgYtHmpEhu7uoJoFELzg55/FkwqXDAg//bJVZbFrmDXk7WHyM+/AIyoD8Wt6zPSphsZ whvY+xVbBx5g03mOidV1JRxzidfuKXWUAiupujdt0z87gJLAFV1LFl2BIeRgc6jmpifo 9IZUyOcm+Nd/hd2iINbRWglyjgJvNgh53ykjVvrHA0ih2I06tZQiNh3f1ho0OydBe7VU 9J5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=sWWX2GTsw+MtALKWmopT7j+jipc7W7igl5gIqNLQGM8=; b=NmqNVPm9R+W5d0PJouLjHlqt/dr4iDQTp1G2xIJQytnNq0OjyGNSzC5iF9TTQL5FTp ufGtBwnDAsp3DTeqQuno4WmtxiaUhBGZpFFEGLOTceef87e0Vci7BGJhAFC/cQeHrkMD oRbkd4G4Q3jC7U0kJX1/xIfe6ifbt7ttxWpZCwlqWEVzLhTTrJniQ14+nBG8RSyjO1yL lD0TpCrrZWyvCzG8Uovwwl99KtovoqCsN46flj53h8eVwPK5AYvfy21wMeuxS6VraVOj cQzIXGkSvVafXcioI5PXqcBZzI6ai6o5RxRRVVjDbaJ2xbZNYvtH3KSMH+8Wawl1GmHb W6lw== X-Gm-Message-State: AOAM530o2VIUEpd2GnliqG9bCb5BR0LzJ0rpWQDxbebIMWuV0zdsf3kl Xi5oX/xHe1++X3ouLoxyvGcVcg== X-Received: by 2002:a17:903:1210:b0:151:fa59:95ef with SMTP id l16-20020a170903121000b00151fa5995efmr12993125plh.57.1650319969360; Mon, 18 Apr 2022 15:12:49 -0700 (PDT) Received: from [192.168.1.100] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id i2-20020a625402000000b004fdf66ab35fsm13731333pfb.21.2022.04.18.15.12.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Apr 2022 15:12:48 -0700 (PDT) Message-ID: Date: Mon, 18 Apr 2022 16:12:47 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: =?UTF-8?Q?Re=3a_=5bPATCH_v2=5d_fs-writeback=3a_writeback=5fsb=5fino?= =?UTF-8?Q?des=ef=bc=9aRecalculate_=27wrote=27_according_skipped_pages?= Content-Language: en-US To: Linus Torvalds Cc: Zhihao Cheng , Ingo Molnar , Peter Zijlstra , Al Viro , Christoph Hellwig , linux-fsdevel , Linux Kernel Mailing List , yukuai3@huawei.com References: <20220418092824.3018714-1-chengzhihao1@huawei.com> <587c1849-f81b-13d6-fb1a-f22588d8cc2d@kernel.dk> From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/18/22 4:01 PM, Linus Torvalds wrote: > On Mon, Apr 18, 2022 at 2:16 PM Jens Axboe wrote: >> >> So as far as I can tell, we really have two options: >> >> 1) Don't preempt a task that has a plug active >> 2) Flush for any schedule out, not just going to sleep >> >> 1 may not be feasible if we're queueing lots of IO, which then leaves 2. >> Linus, do you remember what your original patch here was motivated by? >> I'm assuming it was an effiency thing, but do we really have a lot of >> cases of IO submissions being preempted a lot and hence making the plug >> less efficient than it should be at merging IO? Seems unlikely, but I >> could be wrong. > > No, it goes all the way back to 2011, my memory for those kinds of > details doesn't go that far back. > > That said, it clearly is about preemption, and I wonder if we had an > actual bug there. > > IOW, it might well not just in the "gather up more IO for bigger > requests" thing, but about "the IO plug is per-thread and doesn't have > locking because of that". > > So doing plug flushing from a preemptible kernel context might race > with it all being set up. Hmm yes. But doesn't preemption imply a full barrier? As long as we assign the plug at the end, we should be fine. And just now looking that up, there's even already a comment to that effect in blk_start_plug(). So barring any weirdness with that, maybe that's the solution. Your comment did jog my memory a bit though, and I do in fact think it was something related to that that made is change it. I'll dig through some old emails and see if I can find it. > Explicit io_schedule() etc obviously doesn't have that issue. Right -- Jens Axboe