Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6266142rwr; Tue, 9 May 2023 12:39:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CTRCwrc5KAGf06tYXZaWQHRtPGAc7Lm24CLUNzfljoD55I87lGV8jCsJjRHelYdDzoIoJ X-Received: by 2002:a05:6a00:150b:b0:645:c730:f826 with SMTP id q11-20020a056a00150b00b00645c730f826mr12768706pfu.24.1683661166202; Tue, 09 May 2023 12:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683661166; cv=none; d=google.com; s=arc-20160816; b=jqASyggau8DqZg0K9HdGxVEAervmE0SecHazg9/luelvKJQNQS8TtTEEU+6S237HVW dz0NtbeUtIFd7sPE2wBtMFz205y/mYGBNUYtB05CaZYPixhFds0SkJz3Qopwi0+a/dY/ DcytRmFaWJXIkwe8boInklmnx3FvBpXNzrAGLPYVb54sdb4z/LKHDGAicWxkSMcMKOKm e6GR4NeCkN4uxQIfecOXMIwJ0fmWFWKW/IgLPLKFPQDaC4q874ChzKpTDDRyKTruC+ND Feuv1KY0b7cZw6ohTBoeWSZ86qrlWh3YT7djr3IYla/LBbg+Zd49FrS1N86lGDk9ENT7 n3Ng== 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=+bt29R0emODDcrX+m6X0axLc75RE5wWtz5YBIQloRJE=; b=a1lC+YXrIgfuHKWEB/PE7X5Lxhj8Md1ubA2O0FjelRRcHmB2Z9I0LmHTm541le9G6m 8tyKLBBjN7TL27MnlWPMrQp7WuzcmhUUZnYG34LpUZ5vsCIxp12ceuoNpOwbvjCrokA9 4d7B9xYXpkDAmZBBpnfu6DXIfXw7JPKHwxzoGvLyErn4nxP6+KusX6IhVAhgOlVZszk6 p9o3DzDqg/VMU+jM8T4RB5L66vIqxfPcAzBMwWRO/zvaB8ZTdxY8UK9AvwyjHkutkJFt QXTzzI+cMb34OoII2MHo+ra3PRU6wMcKNWEf7Wgj62YhKAABMa6JJ7N09QZNembwrKoQ h/CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=legh+RLH; 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 w30-20020a637b1e000000b005303a36c1cdsi2253746pgc.423.2023.05.09.12.39.11; Tue, 09 May 2023 12:39:26 -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=legh+RLH; 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 S233354AbjEITYH (ORCPT + 99 others); Tue, 9 May 2023 15:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjEITYF (ORCPT ); Tue, 9 May 2023 15:24:05 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 914D819D for ; Tue, 9 May 2023 12:24:03 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-3f3a287ecceso3307131cf.0 for ; Tue, 09 May 2023 12:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1683660242; x=1686252242; 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=+bt29R0emODDcrX+m6X0axLc75RE5wWtz5YBIQloRJE=; b=legh+RLHVRlEJGk4YX5eD6Wfyy+I8dXIqpy7+jcKqddZz4Y7QzfoGiAWbOP+xXSBkF IkEkEAW4HEOg9wwbwuMXwjHROSmfxzenr9+ex6yA97e84jXR2R9jGzVJ6UjfQ6Qoeo5G 0JJ5O0bEYjHYQw08njP5ge8zujYLKVlEnxtI9Me7y09m4L21np7hmyqXGVSnOMdQg7+g az0WE+LGCPGCa3DSVT/sSVUM+aAM+tX0P9M6LCf+2tdQEPHdNozECaLnBckQ48t9NjX5 GarumBLerCa1YelkJbEhQqRKTIRS3Q2gQgPe0A52X1AynE6AGZPbquKIOx1Q3c7/8wRh VDtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683660242; x=1686252242; 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=+bt29R0emODDcrX+m6X0axLc75RE5wWtz5YBIQloRJE=; b=Kgd1u11LpMeG7asJV/ugyupHjGzL/xYiJ49NB58b0uvi3mIFPXwE2ULwfsmG7sBShB NMv5UTKBJJH8kFFpKKJLBli10yFLdzOIMDjhbmmH9sW7DGdcyVp+nH658d01KJZtK75V YZYWTuuxiCLiu/KBLWn/DwUVQTiZbqpT/6hsdZ5wQ+CbGoKWJ8fRsPk8dZoPhSNFOsP5 3XMW/15TOV/hCffevYh3CrtgCo6zkdWoU7w7cL5CNUl6zUwuUdgkHdOlRacDHOyMConj ZvGLieWbmfKnhNY8R08MefWGSrSdw5HSce5Gax9isNhcGfhEqiwYtcs7ZRNcJh7WCjfD ovKw== X-Gm-Message-State: AC+VfDzANvdi9QMZ9UTcsS+dJ2+gAQ5ME7SNKFoSGO1f4+iGGzAg/FRO lKwIKlQ7Y3ht7fF31h2621xRCQ== X-Received: by 2002:ac8:4e8b:0:b0:3f3:8cf1:629c with SMTP id 11-20020ac84e8b000000b003f38cf1629cmr13989131qtp.46.1683660242726; Tue, 09 May 2023 12:24:02 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-8f57-5681-ccd3-4a2e.res6.spectrum.com. [2603:7000:c01:2716:8f57:5681:ccd3:4a2e]) by smtp.gmail.com with ESMTPSA id p22-20020a05620a113600b0074db94ed42fsm3443283qkk.116.2023.05.09.12.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 12:24:02 -0700 (PDT) Date: Tue, 9 May 2023 15:24:01 -0400 From: Johannes Weiner To: Minchan Kim Cc: Sergey Senozhatsky , Nhat Pham , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ngupta@vflare.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, kernel-team@meta.com Subject: Re: [PATCH] zsmalloc: move LRU update from zs_map_object() to zs_malloc() Message-ID: <20230509192401.GC18828@cmpxchg.org> References: <20230505185054.2417128-1-nphamcs@gmail.com> <20230506030140.GC3281499@google.com> <20230508140658.GA3421@cmpxchg.org> <20230509030030.GD11511@google.com> <20230509174401.GA18828@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 09, 2023 at 11:20:02AM -0700, Minchan Kim wrote: > Hi Folks, > > On Tue, May 09, 2023 at 01:44:01PM -0400, Johannes Weiner wrote: > > On Tue, May 09, 2023 at 12:00:30PM +0900, Sergey Senozhatsky wrote: > > > On (23/05/08 09:00), Nhat Pham wrote: > > > > > The deeper bug here is that zs_map_object() tries to add the page to > > > > > the LRU list while the shrinker has it isolated for reclaim. This is > > > > > way too sutble and error prone. Even if it worked now, it'll cause > > > > > corruption issues down the line. > > > > > > > > > > For example, Nhat is adding a secondary entry point to reclaim. > > > > > Reclaim expects that a page that's on the LRU is also on the fullness > > > > > list, so this would lead to a double remove_zspage() and BUG_ON(). > > > > > > > > > > This patch doesn't just fix the crash, it eliminates the deeper LRU > > > > > isolation issue and makes the code more robust and simple. > > > > > > > > I agree. IMO, less unnecessary concurrent interaction is always a > > > > win for developers' and maintainers' cognitive load. > > > > > > Thanks for all the explanations. > > > > > > > As a side benefit - this also gets rid of the inelegant check > > > > (mm == ZS_MM_WO). The fact that we had to include a > > > > a multi-paragraph explanation for a 3-line piece of code > > > > should have been a red flag. > > > > > > Minchan had some strong opinion on that, so we need to hear from him > > > before we decide how do we fix it. > > > > I'd be happy if he could validate the fix. But this fixes a crash, so > > the clock is ticking. > > > > I will also say, his was a design preference. One we agreed to only > > very reluctantly: https://lore.kernel.org/lkml/Y3f6habiVuV9LMcu@google.com/ > > > > Now we have a crash that is a direct result of it, and which cost us > > (and apparently is still costing us) time and energy to resolve. > > > > Unless somebody surfaces a real technical problem with the fix, I'd > > say let's do it our way this time. > > > > Sorry for being too late to review. The reason I insisted on it was > I overlookeded the bug and thought it was trivial change but better > semantic since zsmalloc provides separate API between allocation and > access unlike other allocators. Now, Nhat and Johannes provided it's > more error prone, I am totally fine with this fix and will live it > until the LRU writeback will move out of allocator. > > Sorry for wasting your time to hunt this bug down and thank you for fix! > > Acked-by: Minchan Kim Thanks Minchan! Domenico is working on the LRU refactor right now, and should have patches for review soon. This will indeed get rid of all the zsmalloc warts and make our lives much easier going forward!