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 B1FADC77B75 for ; Tue, 9 May 2023 19:24:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 049976B0071; Tue, 9 May 2023 15:24:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEDF96B0072; Tue, 9 May 2023 15:24:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB5896B0074; Tue, 9 May 2023 15:24:05 -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 CD5B56B0071 for ; Tue, 9 May 2023 15:24:05 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7F3641C7536 for ; Tue, 9 May 2023 19:24:05 +0000 (UTC) X-FDA: 80771692050.19.DBF54DF Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by imf27.hostedemail.com (Postfix) with ESMTP id ACB7340003 for ; Tue, 9 May 2023 19:24:03 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=legh+RLH; spf=pass (imf27.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.175 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683660243; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+bt29R0emODDcrX+m6X0axLc75RE5wWtz5YBIQloRJE=; b=DwR7D1UnoGTv/aKtLBzJHgv79tzR6ejSn/3TSqVtyYC62Xm2FSKaP+FZQAr+fhCnin2ejM i3UhEXm64WcyCjXTp58TbfPV/ziYnSRd3pPrxkVDEKKNOBg2A1EQulaCeVnb8czfqeKECU Y/ZsYAFdw3F9dLxTiOHxW3koUlMIIRI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683660243; a=rsa-sha256; cv=none; b=kijR7cNj8fRjrY5EbQAQ3TCei3cs2+vvAWsPhCXdCiTWT9jzCmTNbGImroBBtGjrrkZg1e 4E5wmPfn+HsTGsRZk+jdBZalbjFb/xi6De17Tw1+abepzWGMIYQ+47qKpAsMvXQ3jXuf8f By0/NeJnDOLoX8HoPwpoelimZ0lWvR0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=legh+RLH; spf=pass (imf27.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.175 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-3ef3ce7085bso29915591cf.2 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=Vyo469MaPzKuqPFKN8s8Ovayg5hHZ8TaqJ8u48UOwfCPORsCvZPY/jdnjzHq1dgRur j+CiF0vKUkvepQvORWyOgcdDzGNg+/Cpv61biWqjzKlbWdmBoHhSJzEOduzIlK8Zb+kr Vc9BZDHqSBYLoZDUjqEOUQbNrYAa8+ddGGqls6i3JgqctRdQ6LphQQMClDdTT1mFFOxw MEFrVLtLq8dBlfRjasUhey20DH6f9ejc9NjH/ecvmS+xWzTTrDvWzSwfxUBziG6xGfuD ER5httsqMmaTXAyEg68Fs0atCuijK9JQ7KH9IVVyBqd/WuDQK8G6H9j+Da7GlhAkKCKh 6ONA== X-Gm-Message-State: AC+VfDyDpvqZPPpZG7L2uYIAoUdWcvc9OD8fd/B7hDjG4A0XcdLDSm/Z xvDADaxHdIZS7g+VV0hBBClHnw== X-Google-Smtp-Source: ACHHUZ6Qh8xl9aZWQDgNJesbKNtoZJwvFElUj56yG3HNcuLM35HG7mif5nUmYciKnsSy/ZdQUYzypA== 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-Rspamd-Queue-Id: ACB7340003 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: 1qx1oh1xs5xwqmykhpfbru8tugn7mrum X-HE-Tag: 1683660243-713364 X-HE-Meta: U2FsdGVkX1/cIRNgCh/c5t7ck03iOt1k3jmi98siqAdKHzgbipSSTKByyfKA+x+ttB+U+giPZaN8DvhkDn1I2mpWVTwc3WGRTBM/L1mLGwU0XRuxFHKpnt2VGy5vFgdW+mn7zamxhuCoLcnbPrFQwLBOOTigRjpZFf9SpGNK1UEWfiiVnslZQsOVbbQt9jA5uMb63G1YtWG+94+23/DqEKGxg0uHTOniRNDZwmHZVplN+7uEQaIyERVMmUKYSp8eTys77qAB9phM/R/vU3kAaUKlqYUoaW7lHC57LE7MVcs8SGcDONYuEZSkH29yqT5kOwZ9CHkzXUoRVApKZy9h5o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dDTvPqujTLFY/bpwNepMDMtitM5mC3r/PUCWAyRwpW6bODfYamQytJdNOx25V1+Oj0w0Fiu8zbZPUo134/Ct+g7YG66w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.169410, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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!