Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp20223pxb; Wed, 30 Mar 2022 21:42:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJwR9HacEc508RfHn63aJhQY957TX3DSWemb7mRLEXM3AU9UKWzaHbTuGF6pw6iqKJwp58 X-Received: by 2002:a17:902:bf04:b0:149:c5a5:5323 with SMTP id bi4-20020a170902bf0400b00149c5a55323mr3231305plb.97.1648701737533; Wed, 30 Mar 2022 21:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648701737; cv=none; d=google.com; s=arc-20160816; b=oVLc2UjZ7qw+9fzk9MGlvLAF907AM4b0YvmJBf0QJ/fP/CXBm7CqFKgGWeSiUhLKHc e0oj3eIcVcfLcl5VROMYCjJ+l/HdoJE8Dt6sVia8oGQrQAx+YO6J7g5VA82ucPBEeKHh gZ7Tej7XZkhTq1GJUNwhVAVrAZtgFpTfq/qe4iOGVU+AzP4i4XPryaY/Mxg8l3aTi/yX UjZW1SBJ8g8RLiCRGKv7ZQJHT2pxD35ENogSIgPq9qtf8g76zq3jo6oN1jlHjzKDgOjB zigLo+66q3ZfAA8ZcwHvxixBVC1e8lFREfl2fDaf8QVREHCkGCMPLn/3VVTmY8KL7TCP XMKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JKBEI+rTrucdMmAykodBJnjRrK7pFFvDZ/jgsyxJpqM=; b=AX9dIOROKGZbAbAhB24QVZMZTx1cha+3YFvAI4u58XMSD67rRn16fTl7MYclclhwd+ 4qR3c1CeWQ4YOpWREWW0wrC73POcgICN893IM7jawOvHcIR/B5Wwo1ov4YT34aj0fC8i X7pJ/Wd5+mBe1yp7Z57I4WDOg5z6MD+7JXlJ1DcRPECSLU5b3asODxAieVUvIz9p2NoT bwaicnMV9tkvBnxOLhifgbfS6xETB1Pl8pLWIbkg3PtPOnp8Crt+5wby4QbuW92pSHmX wfJ66REaj8azOGFtCTxUWRDQihAJ+bNwAWXc4Gem+EsVbsJpI3Rl4wVMg4zdCkI+UeDG PKSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=ZdgvW8Lj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r71-20020a632b4a000000b003816043ef3dsi23675728pgr.306.2022.03.30.21.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:42:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=ZdgvW8Lj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 08980260C7B; Wed, 30 Mar 2022 20:38:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345552AbiC3NCg (ORCPT + 99 others); Wed, 30 Mar 2022 09:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345549AbiC3NCe (ORCPT ); Wed, 30 Mar 2022 09:02:34 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F06D15DABD for ; Wed, 30 Mar 2022 06:00:48 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id 85so16484542qkm.9 for ; Wed, 30 Mar 2022 06:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JKBEI+rTrucdMmAykodBJnjRrK7pFFvDZ/jgsyxJpqM=; b=ZdgvW8LjgNL6YoqgHEh9gCT/a5BIEEXhlqaP97vLxTw5UtMyWwZgMFoScg41CskVB5 tfMc3uKjFABrduUmfVVkRLPZMnDclwcFUEMNSYizSlVlLS4Cd1MArP6pc0/518t70bGn bpXnOF4LwesYzcGZuUUFRmY5SJ04C+LezJNIr4BgOJ5Sczzn/GnzoKITfFSLprFCsTyx zZO8/lzwF0pNVYBojwrJCtCG9mmLOAuLtcz+TfGA4ArRPEXMlYYFYPHJblLHUZqqQPNQ oJKncFZRx8keTMZvVHfEluKg6hVvsYHpFxir/BDXwROVBfk7CLo3OHP5QpZ5nvfSqsXF a5Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JKBEI+rTrucdMmAykodBJnjRrK7pFFvDZ/jgsyxJpqM=; b=PtWnAoAKoEMTbumrg8QJf1D/bvUblrJboGmK+0x2Dk6Oa4P2q1t2pdM6NbZh6V95BQ oDjEaKr0M+5mfzz7MsAXOEJx4EaRuJwbW4wtsifq5hC4nuNtbdSP9R4YZwehxgejuQBw +hQe/fpUMp4Zkn5+E5eo0CRQKaMiwB25iSKbBddXxd27MoMMxOMDGwYCmN/pZU3d6Tj8 3NFcPgNsAf6VYggM2wSCA3Tg79C+Tkqv6I9NhjX0G+nUCjxajL3Uic/3rqqJY4dImFJZ QtcKIkocpgXAi5xlZ7MAyPIjBD5DQlkj1iETuMIN5u11Ju6R1xH0Z3+P1g6u89+EeEhk CPDw== X-Gm-Message-State: AOAM533QIKER0VRdhmhRZC82qwzCOp2m+YAw3GXMqmBaNqta3jvJJBtt 3l0HQD73DJx0YLq37N4mgHrqbw== X-Received: by 2002:a37:9d7:0:b0:67e:85d2:2417 with SMTP id 206-20020a3709d7000000b0067e85d22417mr23645632qkj.753.1648645247377; Wed, 30 Mar 2022 06:00:47 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id b202-20020ae9ebd3000000b0067b11d53365sm10850997qkg.47.2022.03.30.06.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 06:00:46 -0700 (PDT) Date: Wed, 30 Mar 2022 09:00:46 -0400 From: Johannes Weiner To: CGEL Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, Yang Yang , Ran Xiaokai , Christoph Hellwig Subject: Re: [PATCH] block/psi: make PSI annotations of submit_bio only work for file pages Message-ID: References: <20220316063927.2128383-1-yang.yang29@zte.com.cn> <623938d1.1c69fb81.52716.030f@mx.google.com> <20220323061058.GA2343452@cgel.zte@gmail.com> <62441603.1c69fb81.4b06b.5a29@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <62441603.1c69fb81.4b06b.5a29@mx.google.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, Mar 30, 2022 at 08:34:08AM +0000, CGEL wrote: > On Wed, Mar 23, 2022 at 06:11:03AM +0000, CGEL wrote: > > On Tue, Mar 22, 2022 at 09:27:58AM -0400, Johannes Weiner wrote: > > > On Tue, Mar 22, 2022 at 02:47:42AM +0000, CGEL wrote: > > > > On Mon, Mar 21, 2022 at 10:33:20AM -0400, Johannes Weiner wrote: > > > > > On Wed, Mar 16, 2022 at 06:39:28AM +0000, cgel.zte@gmail.com wrote: > > > > > > From: Yang Yang > > > > > > > > > > > > psi tracks the time spent on submitting the IO of refaulting file pages > > > > > > and anonymous pages[1]. But after we tracks refaulting anonymous pages > > > > > > in swap_readpage[2][3], there is no need to track refaulting anonymous > > > > > > pages in submit_bio. > > > > > > > > > > > > So this patch can reduce redundant calling of psi_memstall_enter. And > > > > > > make it easier to track refaulting file pages and anonymous pages > > > > > > separately. > > > > > > > > > > I don't think this is an improvement. > > > > > > > > > > psi_memstall_enter() will check current->in_memstall once, detect the > > > > > nested call, and bail. Your patch checks PageSwapBacked for every page > > > > > being added. It's more branches for less robust code. > > > > > > > > We are also working for a new patch to classify different reasons cause > > > > psi_memstall_enter(): reclaim, thrashing, compact, etc. This will help > > > > user to tuning sysctl, for example, if user see high compact delay, he > > > > may try do adjust THP sysctl to reduce the compact delay. > > > > > > > > To support that, we should distinguish what's the reason cause psi in > > > > submit_io(), this patch does the job. > > > > > > Please submit these patches together then. On its own, this patch > > > isn't desirable. > > I think this patch has it's independent value, I try to make a better > > explain. You missed the point about it complicating semantics. Right now, the bio layer annotates stalls from queue contention. This is very simple. The swap code has relied on it in the past. It doesn't now, but that doesn't change what the concept is at the bio layer. You patch explicitly codifies that the MM handles swap IOs, and the lower bio layer handles files. This asymmetry is ugly and error prone. If you want type distinction, we should move it all into MM code, like Christoph is saying. Were swap code handles anon refaults and the page cache code handles file refaults. This would be my preferred layering, and my original patch did that: https://lkml.org/lkml/2019/7/22/1070. But it was NAKed, and I had to agree with the argument. The page cache code is not very centralized, and the place where we deal with individual pages (and detect refaults) and where we submit bios (where the stalls occur) is spread out into multiple filesystems. There are 180 submit_bio() calls in fs/; you'd have to audit which ones are for page cache submissions, and then add stall annotations or use a new submit_bio_cache() wrapper that handles it. Changes in the filesystem could easily miss this protocol and silently break pressure detection. I would prefer the annotations to be at this level, I just don't see how to do it cleanly/robustly. Maybe Christoph has an idea, he understands the fs side much better than I do.