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 593A5C7EE22 for ; Tue, 9 May 2023 18:27:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA94A6B0071; Tue, 9 May 2023 14:27:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B32946B0072; Tue, 9 May 2023 14:27:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AC236B0074; Tue, 9 May 2023 14:27:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 845446B0071 for ; Tue, 9 May 2023 14:27:23 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 21B64A0845 for ; Tue, 9 May 2023 18:27:23 +0000 (UTC) X-FDA: 80771549166.10.6EC34E8 Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) by imf17.hostedemail.com (Postfix) with ESMTP id 45A1940009 for ; Tue, 9 May 2023 18:27:19 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=OanoLY0f; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf17.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.166.48 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683656840; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cEDIRdHz9e6l+8TjKkRbmCBTlSMnPPPrLZQHvlvOjxs=; b=JGD8WwSTmGUk/ptA7sTwiNCwMqL3wuLUYJq1WAK73PdbgrI4E68bEdL5u4eoXn1cahIIH4 OOKzquX+fhG32JDGSBaOBR8lAiLoSCuZCDjOGLR9bu1KpXLD2gmZPWteVmXbwNO3SPLp2g 7zt8npkd699NJ9EKpAsm4QsZoO/hS8A= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=OanoLY0f; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf17.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.166.48 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683656840; a=rsa-sha256; cv=none; b=UIa6Y1EeLFMK9khIir5zHgpZazLB6/ctQV5ZAOweWxc54srfS+Ck6n3Nqk6IybqJdexnjF LEjas6piCNdOrkFBtW6KFSmWk7MToUUf57XJ+S4sy399ZXQvlFzt4cYl3uQm3cb5mzW6AB ocBSHMTCuD007IYHcxZqjwQBrrq3gE0= Received: by mail-io1-f48.google.com with SMTP id ca18e2360f4ac-76c60c88d0cso52343339f.2 for ; Tue, 09 May 2023 11:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683656839; x=1686248839; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=cEDIRdHz9e6l+8TjKkRbmCBTlSMnPPPrLZQHvlvOjxs=; b=OanoLY0f1TQbtdaR3yoD1gDpb5F2upaWWM3xKay6ktkO+xAJwIyqbXrQIL/79vJ0Ep 3AVBXFvFbrL8wNmuY8hv7WDU0fFTEhOzuRU45esBq+2JCAiIFoB8nzK3jGZLfMRQ839p rznh8aMzpE/LQrQYPN8E079jNza73PLEiuWN9rbesIppNUe8JFtmy5hDLIGQLQ7G1ndb Jc/QbVykoIY/xpwFh5E5RkEBWSFDY96wUwqP/itkxg8CC+jmq6JRvXprjvHOeOLUZgag 91jplO+2FE2B1+ua8/Xu56Agf0zI6BsxxbL3LK7ETAKIBh08r9rRLZTG/wpfaInB1bFX 7TpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683656839; x=1686248839; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cEDIRdHz9e6l+8TjKkRbmCBTlSMnPPPrLZQHvlvOjxs=; b=MrxfC0goW4x53XkIY69uOHwnfyHtR0Bxjd4WyDskrNZBy3BL5saifi5bxDsm3F18Ba ZzEoSUXDUSM+S3KE2rwNwD+7XpDjC7bQneKEvdBmm0HIWDpMU8hY8Zwmex3E7Rfn5B33 2L7jn9yW66Ye5ugqCjjygcvpD6UhGNB3FZiaJymYzBSXRrbm99L6mddPTaGsV5JS1QOV NLwS1ajzkvFS0PVzbm9cnNzjCm8jw8vl7aBr6NLs2VklQa/4d26I2vf6g4MRrU+sXJMP kb8k3yu0Tr5x9sPrWYy5Gm5VND5ttBFhpwQaz3nMkqRXLnYVEUSxpVULdoe8P8vqBAcO PuLA== X-Gm-Message-State: AC+VfDzb6+ACxX31Ty4qbPQwNOVI40SnFP9syUsHck41GcznJrNqhZdx BpdtHblSR4t8/sEWswh8v/mWW+o4fc4= X-Google-Smtp-Source: ACHHUZ65f0Wg+ufT5KKdEi3378XwhvRduo8TpUGC52oRId0a9c73zP+cO09zEQXCZuTlfug93Q/PQA== X-Received: by 2002:a05:6a20:9192:b0:f4:ac2d:8ea0 with SMTP id v18-20020a056a20919200b000f4ac2d8ea0mr16871956pzd.32.1683656405741; Tue, 09 May 2023 11:20:05 -0700 (PDT) Received: from google.com ([2620:15c:211:201:edee:934e:dd3a:5a4e]) by smtp.gmail.com with ESMTPSA id 20-20020aa79214000000b00640dbbd7830sm2161403pfo.18.2023.05.09.11.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 11:20:04 -0700 (PDT) Date: Tue, 9 May 2023 11:20:02 -0700 From: Minchan Kim To: Johannes Weiner 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: 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: <20230509174401.GA18828@cmpxchg.org> X-Stat-Signature: 8uhqf1twbdwar343zseos5fr3haqzrcs X-Rspam-User: X-Rspamd-Queue-Id: 45A1940009 X-Rspamd-Server: rspam07 X-HE-Tag: 1683656839-387453 X-HE-Meta: U2FsdGVkX194xv/geu9uTSLHHr5+nNxzUPIfKmToxMi0SGk1RNXrDVZACwhuG0A+XilpwARjHX5qQZSyYkH2iljNcbI1TVh10caDpnLDOrVXP93dshiantEq+dpwhjXYtN2bVjYmmUMPvmyq+ub2iwX4k314zWWSVuReB9d9IgcvSS29PPFnTqSwVPUCuE7AT5/W4dB95JObTAZ0BJAMhGZMhs++V/PjvHnlCwzXxAhHaqKoA4+BkmF1MMsHi3BMNI3havk7GqeUY/VwMrHFprk7z4rMrPIUfm9QKoRI+LQx3EvZYLnEL27DpcuptscJOsvFmeecqgdgSPq7CQOGVJGJgMSLi+bDQAkHtvLLMTJBuy4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rvyxsGsz/8T4o2YZugsM1fDEThcIiSYsBvJ+7Dr7av38iyY8S4B8tEj/877u7NrOfgcKxzuc3USSCK6SPwTlvToEhxBRkI/i4S8EHGgkh/cPGiIIhlTNlZkjrST0pRXQJRyj2OrBFgNNeRVyqJvncNhNkrX9q8QUONwaeWlWN8lwv6/Ni8LZkzsB5LiwUBjDhUgwwMwkQBAGP4iawJs8jl7J6XOsZu2qlRatJFkVp8XDVk7TwizDsoEVK1nd1MRqeYY/+KUaaVy1BTRr4VVJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000019, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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