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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24A2CC7EE22 for ; Tue, 9 May 2023 22:04:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90FA76B0071; Tue, 9 May 2023 18:04:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8BFF36B0072; Tue, 9 May 2023 18:04:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 788196B0074; Tue, 9 May 2023 18:04:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 694506B0071 for ; Tue, 9 May 2023 18:04:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 33E6BADD99 for ; Tue, 9 May 2023 22:04:43 +0000 (UTC) X-FDA: 80772096846.29.AA0E84D Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by imf01.hostedemail.com (Postfix) with ESMTP id 654F74000F for ; Tue, 9 May 2023 22:04:41 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=WGUF6FWv; spf=pass (imf01.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.222.182 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683669881; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QkMWCTTdqslF6xurqfmIDIK6nKUV3PvEA0Tj1gMf8ZY=; b=qCxadyUke+DAvpIh6reERQxLxCDQbGAe/h8bkDWj6nyvyR8Ge8euYuBgcGuE79uEIgaDOh MG2cWXummoYpJxBiGBGkb6tT3iClWGmXljBpv5p5OuQVQyEBOJ1LKSHzbT4MVGLnk+f/v+ 1krpBKl8fEFVptUDwnOOQ6gIGudb+Bw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683669881; a=rsa-sha256; cv=none; b=fYYnbVWt/3iZ5hJCyhFVhjvgyq6Gv1J2IU7iPR3hU5+0r5oTOwFolu9h6ikwnZAoOf2EPg ZFac5SxLHjY6+JWFFOn9eOhoksd1hFzU3jtX/b4Z7FFJcYa1j7DRwljRXphCzb8IP0idaw Ema+LsdE3IPu3GKLuQ0l+YLEbppqSLM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=WGUF6FWv; spf=pass (imf01.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.222.182 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-757741ca000so333974785a.2 for ; Tue, 09 May 2023 15:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683669880; x=1686261880; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QkMWCTTdqslF6xurqfmIDIK6nKUV3PvEA0Tj1gMf8ZY=; b=WGUF6FWv4A9G0XT3CunG7k7Cu0dK+BqpnDHRziwALPVoIzX2TDmFDseCaiIgNOWt0C dN/zK5WK1QZO5CY2vkgJxRMvfOBazOfyqN1D4oO411bdvCqkEcqJN3VQYIx8pIEVv0Lz Ix2TUcV1cmpSmiemZGoZhwLZj/YYpolky15yN44W/mXDQKAprIE2wWOfiX7CZ+kcA5To fLrS2QBtf/pqCDiS6wHP9lbkyEhZb26yYAgsQ7346v5NSOLaqOk2WHzU82dEQwAw/VaQ ks9OkWSHZEio+zHqcK6wpo+L/1Yv2A9mXHazh9SCs7X7d6co1rR4ORIvLaCuKuNfZCBL Tkeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683669880; x=1686261880; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QkMWCTTdqslF6xurqfmIDIK6nKUV3PvEA0Tj1gMf8ZY=; b=Gjk4ssz+VoWfeEHtLEZk80vVAPN8NgB/9gbp8yCbVJTwbjcLbhZ3dxGU2/PiCULAn6 7QdmP4z+9vMmlStIhUR9whTsi7xOc/WSvoLm/ONogcKlJbNIZM17JYuGMLydi2VjVDdz WB7/Sx9jBnimL+odgm5FWPkHbk2jA6TbWGPuPJYI+9Po1sWf69uDW8nrcaS42VdsNW2z SxyWA961avUwlWWMTLQcgqL9FVVXPPEE+rDA04R+TD4FMvhNEbh/AtAO/HcPO4O1NQm7 rzquqphktyityRtp7SjKcPjvAUu8qKVkvu/yzcNmgdmzvgBjrpT5vhAkYbV7BWlGw0DG kBkA== X-Gm-Message-State: AC+VfDwgNwZTcbD5kHdLwYHES9BISeL8wjGl6bR6ppXcT3gq0wp6yW5N z+Hv9AK7UNkHl1GuLSX4j+nYp5T/M8dL7PXYuBw= X-Google-Smtp-Source: ACHHUZ7p8eMJoVKrr8QGzh2aTEIq9zqFzqaog3OgUjE/YvaL3i2yUfyT5U+G1gpF8pk3DJqZi2pOTN+kvcjvvHOQp2Q= X-Received: by 2002:ad4:5961:0:b0:621:4551:c6dc with SMTP id eq1-20020ad45961000000b006214551c6dcmr1407759qvb.39.1683669880257; Tue, 09 May 2023 15:04:40 -0700 (PDT) MIME-Version: 1.0 References: <20230505185054.2417128-1-nphamcs@gmail.com> <20230506030140.GC3281499@google.com> <20230508140658.GA3421@cmpxchg.org> <20230509030030.GD11511@google.com> <20230509174401.GA18828@cmpxchg.org> <20230509192401.GC18828@cmpxchg.org> In-Reply-To: <20230509192401.GC18828@cmpxchg.org> From: Nhat Pham Date: Tue, 9 May 2023 15:04:29 -0700 Message-ID: Subject: Re: [PATCH] zsmalloc: move LRU update from zs_map_object() to zs_malloc() To: Johannes Weiner Cc: Minchan Kim , Sergey Senozhatsky , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: thd853t3hd13rjtac1woy6oidgb6e18p X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 654F74000F X-HE-Tag: 1683669881-330185 X-HE-Meta: U2FsdGVkX186TZJaEn+OPZo/n/n0r1mT6R8umOoVmPvpwYc2fEDNNoIDCsRN7mhhASZvgYDjAYXDJxkKG9bekOkeyJx91MUWtVAoae+OTd0HYIeHQnd85yfyskIKD1xTKAo404kW241neeQlC6ed/EDTcGgfQzSjFoJx4fNWlYLKd+ulJVfY+eTmiCGSGXNKV7dOCAYpKk1JoEzo53jo14uk2h4e+JWsbf7FUxcSIsjlvxpQviefefePKhZxULSpLQTznc5p+sL9vJom7ncmqHGx5ZN/APWOYcM/nIdOW0IBjXgn1+HzyErVbcaLTSjadGACK/XKiU/gTQ0QtV/QxV6qMsoPIJpWw4a3QAN4RutUja8w8IxW74CgZBls5HX03bppFjqiiEM9nPRz9H4I9u6CIh5ypeyUJcuxvAAKzsJLGy/5s3DCfmzQAiYZLvXhvaMadnhzRECU4u5MNTxO4nzxna7fK0Gi/9WgFHICFyQdfEY4VlyWNecVHI+SGUKWVO0vlPZm+lUyA686fodNa+W5RWrFGlX2JirmTStAMOnpVO9BAeKvMveKHoshJX2ZykGDUnZ+Z6fFyMCseGkm7QT6cK+LJMT+dO934C9rMVHRyGtWccgHop3MnMNuTSu7Ql09wwKXyatubbbwbm5YLE+Vauabntn0t4yopUKYpxDb2gF34H2V3E+9fftlLGb9JW1D/lbWrL3zTXi3NQhPnAGgyk/Dz841JW6ojvNH1W6CEzR3sWaH+BWeY3ll7Ojt6JAexElanPwzy/chDsxnFGZNN7omEtLe5UIa09mzmDhbpRdEy4VXIEH3B3Hbf0a15kLOE8dPOUnm5ayfCVljSqxIghj/D0rPHaz5BWAFrYHcaoD4TmAl8yi/YaEXcNxB7VR/eGa0PGVuJnNVeb2r7omy0YuJof/PcTbBdcnmCW2GmhmG30+wzHNMRWyda07OI7yx1NWXLaNUuHc+u9U 9a0EkGxF hIPf5aJkq/mPv+rgHcc8B8xoiStXerf15qo7siBeq63IOByAtZTWRck+NpxJsbG1HbTmd1Fb78hd+EASTKBlCYpPsXpP/398bWXsV1QnJsLHwaS1LgBRCMKt7G3NIAhIrO+ximeu1umaC3C1tGYqQPcu2LCDKW91JXCYSDliySYlmErVkYd2NsbeuID5HdXIMy8t9wezdy3A/ir9ujU1lCvHNMn5sdh7lz6z+ClvF/L14M3K3t02ENnMEGPCurs9n+NzaXMbP5JYhHklK1G4bbMPpdWk9ajClLqDM0AQ/RUbpFZdlVTWWTceQ2THMdp0o9SgEyCby1xVWFnar7o04VVuEyXlG0sl2kH/6+5j9uFENCze6LSIUowPthuwLzXiUM++ACzwDK/p3Q6LooB+yvx/r53Xm4NSwcUW/fBje6AtMYKAM428BveL13r9WeOxSSlFOt9Pyvl4r+APDmYl5GuvqGHtDx7/26DvQioxzz739pX15TaUARpFXYRKXBiccPdSz X-Bogosity: Ham, tests=bogofilter, spamicity=0.246291, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, May 9, 2023 at 12:24=E2=80=AFPM Johannes Weiner wrote: > > 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 pa= ge to > > > > > > the LRU list while the shrinker has it isolated for reclaim. Th= is is > > > > > > way too sutble and error prone. Even if it worked now, it'll ca= use > > > > > > 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 fu= llness > > > > > > 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 =3D=3D 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 hi= m > > > > 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@googl= e.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! That's the dream! I look forward to Domenico's patches. And thanks for the ack, Minchan!