Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4937881rwd; Tue, 30 May 2023 12:05:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5UgRt+eNzWN1ZU1VMgQhTRS1hSD0IcuXmPrSl3m6eAl9OHVtOM1dKKHkz4nIFkEe8DNpT2 X-Received: by 2002:a17:902:8546:b0:1ad:dbea:6e09 with SMTP id d6-20020a170902854600b001addbea6e09mr3028668plo.66.1685473537732; Tue, 30 May 2023 12:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685473537; cv=none; d=google.com; s=arc-20160816; b=uBg8X6552muIfc6e9RE4bXBiqUR7iXLpnGYi2o9MnhP8HpVd7HeYw45+/ZhqtWbSkR FSOT0F4KJVWqNYdeWqCQdEiDr7TcSdkb5j11wtNPMCeIBDRyfxxMQbsK6RJ9ldr0dLqW yfLEbMXVuoPhDpvJc7hmHwesO0lXorj6IYhtRDcEZWfDjZTZU0F/6QsCSol6gq2GQGPJ I8izAOyyAIL/MsGXCssbba1n4Oglqe4n/zc6arj4AEGWqBnp1C6RAqm2yNUqSF3S3VE7 yfuzAPu4mYQqpajZR+SDATcXWCKGE4ZUkWYD6gqaOYq4P6Z9u3HxXnCy4OlZWBNHO7az AEOg== 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=MOjS6CVqlBlukMRZLNaJyPM2L7QGvu6hUflH8GHgCWM=; b=U2aXa26Yx+ESqYFyifWCf703OWTQJLQhp8epOBLCsJxegNTLQjfdJTUItUglg/y32j SPJclzWVA7L/AUWsegJq27M44UWAh6RejFR3xjiSp4/hahc60641fb79c5Sr5FuR8wyk VFB3PpDBXe8tLVh1/wkaaY5VxwjMiReLM6j6ITAZ8WtGuEcD3PcKecksgNx9djWNhQ2D LDPfDjOj24puNmiLRihUcFCdO0mHPgvK6ebcqCr3HL6lp7pyc9QSJIBnrUgB9nVbjDiG wUqIdzXJc95ZSL/F0dz1P3F+7qIo5cxA92IfaUGPsr8IAYQ5x4ke8xhqXtYvOj08TVt2 FF8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=34SfncPA; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18-20020a170902869200b001ac83d19265si10095318plo.291.2023.05.30.12.05.24; Tue, 30 May 2023 12:05:37 -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=@cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=34SfncPA; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232506AbjE3SzA (ORCPT + 99 others); Tue, 30 May 2023 14:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231615AbjE3Sy7 (ORCPT ); Tue, 30 May 2023 14:54:59 -0400 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC48410C for ; Tue, 30 May 2023 11:54:53 -0700 (PDT) Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-62603efd2e3so24500856d6.1 for ; Tue, 30 May 2023 11:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1685472893; x=1688064893; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MOjS6CVqlBlukMRZLNaJyPM2L7QGvu6hUflH8GHgCWM=; b=34SfncPAo+S5Zx6sK6HG/1bJhx8/ATdMJVZMHEQaRT7Y4f3gXOLTXCLR7rblv6YwFk TTaLRJERwM1s6a2jYaBhQMVNtdHEdPoJozenRUFkkQUaITKX2I4Hwv3lhTsbsHgyJiCH zDezfydRMcPlAbojRKJIvoD3zB2AyUBxWKXdDf3YwNKgU2IGL651kVxcxyUjevXQygmY DpedRmrmRkq2pCHQvBhaYwXMwVI8BeVTIAHyizdkAmi7MLlckyT1lI31NWHO06HGZ9S2 36LEDysP9nZ1wbkF0yv2NxaLRh677Pb4wEhLX62qlVeVjyKvpvL5Tv0edR8iNNCuTxX8 fJwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685472893; x=1688064893; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MOjS6CVqlBlukMRZLNaJyPM2L7QGvu6hUflH8GHgCWM=; b=fwf1bvGqS9eP+C5XeR/28dRBmI4Sj4PooJzM2ZdIpbE1vFAoZarWZuYE3eTON1KFwb KZ9gm2rSeOjUnUEASInawEtNfCUUD30WxZeE+PDz59It7eO+Fu6znTkVCVQbOZu4dieu 3x1mMvLM5d8FABRVuMd1eLiSQxVLzll0Pgxx/d9sb/bkoeDooXfo667GSrNvQRpxSpVu +SJpBdU6lX8UTdmm24Ruh6WVaRFNDJF1hu86471m/5bG9W4QiivZb/m0JJA91caWY8ii K4cQGCPePM5nC8nhvpU7heyLn7HQYwMxeKz9GLP3QMoAJzytj/ioZFBEjsQfdFhNsS8F ZUaQ== X-Gm-Message-State: AC+VfDwA3LLfB19EHE4wBqQEW4/dQlL5TItR0EnSsIq2S0KHbKCnlwNv aaH9MLerV9Lbp3TDj1A/D6IGkQ== X-Received: by 2002:ad4:4eae:0:b0:625:aa49:19f3 with SMTP id ed14-20020ad44eae000000b00625aa4919f3mr3525901qvb.64.1685472893062; Tue, 30 May 2023 11:54:53 -0700 (PDT) Received: from localhost ([2620:10d:c091:400::5:8bb6]) by smtp.gmail.com with ESMTPSA id 18-20020a05620a06d200b0075c9779c03esm4318609qky.17.2023.05.30.11.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 11:54:52 -0700 (PDT) Date: Tue, 30 May 2023 14:54:51 -0400 From: Johannes Weiner To: Chris Li Cc: Domenico Cerasuolo , linux-mm@kvack.org, linux-kernel@vger.kernel.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, yosryahmed@google.com, kernel-team@fb.com Subject: Re: [PATCH] mm: zswap: shrink until can accept Message-ID: <20230530185451.GA101722@cmpxchg.org> References: <20230524065051.6328-1-cerasuolodomenico@gmail.com> <20230530041341.GB84971@cmpxchg.org> <20230530155519.GB97194@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 Tue, May 30, 2023 at 11:18:51AM -0700, Chris Li wrote: > On Tue, May 30, 2023 at 11:55:19AM -0400, Johannes Weiner wrote: > > On Tue, May 30, 2023 at 07:51:23AM -0700, Chris Li wrote: > > > Thanks for pointing out -ENOMEM shouldn't be persistent. > > > Points taken. > > > > > > The original point of not retrying the persistent error > > > still holds. > > > > Okay, but what persistent errors are you referring to? > > Maybe ENOMEM is a bad example. How about if the swap device > just went bad and can't complete new IO writes? This is actually outside the scope of zswap, and handled by the swapcache (end_swap_bio_write). Once the IO is submitted, zswap will ax its copy and leave the rest to the swapcache. It behaves the same way as if zswap had never been involved to begin with when the swap out fails on IO errors. From a zswap perspective, there are no persistent errors in moving a zswap entry back into the swapcache. Not just currently, but generally. > > Aside from -ENOMEM, writeback_entry will fail on concurrent swap > > invalidation or a racing swapin fault. In both cases we should > > absolutely keep trying other entries until the goal is met. > > How about a narrower fix recognizing those error cases and making > the inner loop continue in those errors? Right, I just I don't really see the value proposition of this complication, and I see some downsides (see below). No single entry error should ever cause us to stop the wider reclaim loop. > > > > extreme case where it's the only page left on the list, I again don't > > > > see how retrying a few times will make the situation worse. > > > > > > > > In practice, IMO there is little upside in trying to be more > > > > discerning about the error codes. Simple seems better here. > > > > > > Just trying to think about what should be the precise loop termination > > > condition here. > > > > > > I still feel blindly trying a few times is a very imprecise condition. > > > > The precise termination condition is when can_accept() returns true > > again. The safety cap is only added as precaution to avoid infinite > > loops if something goes wrong or unexpected, now or in the future. > > In my mind, that statement already suggests can_accept() is not > *precise*, considering the avoid infinite loop. > e.g. Do we know what is the optimal cap value and why that value > is optical? Oh but it is precise. That's the goal we want to accomplish. The cap is just so that in case something unexpectedly goes wrong (a bug), we fail gracefully and don't lock up the machine. The same reason we prefer WARN_ONs over BUG_ONs if we can, to avoid crashes. That's really all there is too it, and it strikes me as reasonable and robust design choice. It's fine to limp along or be suboptimal after such a bug happens; the bar is avoiding an infinite loop, nothing else. Your suggestion of whitelisting certain errors is more complicated, but also less robust: in case an entry error does by some accident become persistent for the whole LRU, we're locking up the host. We'd rather catch a bug like this by seeing spikes in the reclaim failure rate than by losing production machines. > Putting the definition of precise aside, I do see the unconditional > retry can have unwanted effects. I hope I could address this above. But if not, please share your concerns. Thanks!