Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2965232rdh; Wed, 27 Sep 2023 20:20:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHSsgaCAcKLr/olPA3VLdc2KNZi5Li4RsCofY0d5GoRxz0A0uguPxYEM7AVSiY4Ta99Twf X-Received: by 2002:a67:f5c8:0:b0:452:5b16:c290 with SMTP id t8-20020a67f5c8000000b004525b16c290mr3158vso.7.1695871206829; Wed, 27 Sep 2023 20:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695871206; cv=none; d=google.com; s=arc-20160816; b=BAKQv4ZDZ/qGtHf8c0ODqvQvHgRDMLE9v7hWx9PHnU1jdjIEGbSa1Xh/ppKTMDih0K KPbP3uOxIMMkNlQvAcO7x7QHWhqLIC872EE1oW1sGhYFMAylVORLDQISF/Optnsu6gym 6IPxArRVoFs8PaIfX4td9a5ao2rKDuLX2TJcuhoSBkzV3Asr6/r9ZDfrIsRcT8We6zTW xaDWuKkUCMwh8j6f741BTKLPFMO5iLZPWVzRHdJdX9u8I1plgaBzxFjmDl7Frnui8EHI 6ihNusqBp8ahNbAwzB+P2tw2jjhwZJvuJW03ZZowBBqywl0FXbdOAZJ6cdiV1mIbiJhL x01w== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kRCNzMNNybq7cAu+oy1LC+Etj9MlXZAFVZAiufmH92A=; fh=fz1gTbAo3NK4eUgH7T3Qf0XgI0mvK3xupXVu8Cy324E=; b=x8nNafWfGD+V2DjS+cVrbmCaYCsGMUyvUyYjbqdVjfeO/wI9v4AM5D/A1M0VAn8j6o dWkoU+fblWdOQ83e1Ggpns2QRQjdPjW9bMgl4SbGkTsxq8qKfKdVT0LbvMvLeZRqmCYj 0mXxhgRJW1ao/Gtp6DHuYWx4FkdB0wJ3cdfx/E5OS1a3dtv3wN59+FEkEa6fY6iWn0p+ hCK+rF6VFEK+jFP2380+E7vkG741daFk1chx5U/w+F5q0d8Ki+HQKuenqlIMhBNVK3on y94CrAHKVFlqJ4Gw1VjKmgfBj7IYd/untaRpl36hXCPtw0/FKLhuFf0WRAQVNHSOWM1x lEzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b="Xlzu/GFV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id b19-20020a637153000000b00578a66db83fsi6323164pgn.141.2023.09.27.20.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 20:20:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b="Xlzu/GFV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D777580AEB04; Wed, 27 Sep 2023 13:52:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbjI0Uv6 (ORCPT + 99 others); Wed, 27 Sep 2023 16:51:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjI0Uv5 (ORCPT ); Wed, 27 Sep 2023 16:51:57 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C67911F for ; Wed, 27 Sep 2023 13:51:55 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-7741c2fae49so693906685a.0 for ; Wed, 27 Sep 2023 13:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1695847914; x=1696452714; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=kRCNzMNNybq7cAu+oy1LC+Etj9MlXZAFVZAiufmH92A=; b=Xlzu/GFVefzrGUDyHTZji5baHV0GPkfaleH5J16F3/I2qPimOF9bCqysC4oPQOqmqk d90M4cIdy2to8geX49BJG/UFB6fvwo2au42wmm15fzD/kMRt2AaerwezpLQM6G57DC/z BWzxzwHWA/2GUFlJRwZV5nYC1zCQyWmUxvqsQdW4maOFS3AufHLob4dIG4yiHykOIJaX 5VQv8GXsrh1KGsXZ5V1gSfjn+525nMdqTUoY0XcT8OLC7rO4y6h76zhxLuKpqTNw9vv2 oEwO0KS/RzFbJbeHSMf+ZqkRyNgOiMAg5TcuXLcp27cndRk11sPoeJoMvu3sv3TQhKWb SKXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695847914; x=1696452714; h=in-reply-to:content-transfer-encoding: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=kRCNzMNNybq7cAu+oy1LC+Etj9MlXZAFVZAiufmH92A=; b=FAHUmW5o70lgSDLyCNc/wLVpAikGxlj5XsxsSIyeP5YPgFPYAvnIcHLOmna/gbWtSg aU9Q85583OYxfll8NTm56V5uwoR1RqeDDe69tUN9Y2EEPjHyUMQ8Qzb624N4+xiw5Y0r nJNdXD2pM/hk5NOvSbjknRAsNcSkbiuP0ZGv+Tmn1dGUVgfcBCA6pUsB6KvOZC73Hg5r unpieLirPLzAeF2JP3HvJ4WXPqv+CdHRuiTyW+yWF6GuL/Siq3GacVK45HxPEJWlBCZz +6XNowPEoDEwISU3Ns2kRNa7PkGEzgiSdVsYbDVIwJSC4dtvVCWrm84H4ZBqr/iUlFRx 9CiA== X-Gm-Message-State: AOJu0YygBJb0H4NKJ8evP6a1pK91FOgfYaPojiNnhEzpJrhOyxI1G8kB HhaFBKuSYIwSEngzwWnGPxmRGg== X-Received: by 2002:ac8:4e81:0:b0:403:ac95:c6a9 with SMTP id 1-20020ac84e81000000b00403ac95c6a9mr3566477qtp.30.1695847914504; Wed, 27 Sep 2023 13:51:54 -0700 (PDT) Received: from localhost ([2620:10d:c091:400::5:ba06]) by smtp.gmail.com with ESMTPSA id w19-20020ac86b13000000b00417f330026bsm5001070qts.49.2023.09.27.13.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 13:51:54 -0700 (PDT) Date: Wed, 27 Sep 2023 16:51:53 -0400 From: Johannes Weiner To: Yosry Ahmed Cc: Nhat Pham , akpm@linux-foundation.org, cerasuolodomenico@gmail.com, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com, mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, muchun.song@linux.dev, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Chris Li Subject: Re: [PATCH v2 1/2] zswap: make shrinking memcg-aware Message-ID: <20230927205153.GB399644@cmpxchg.org> References: <20230919171447.2712746-1-nphamcs@gmail.com> <20230919171447.2712746-2-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 27 Sep 2023 13:52:02 -0700 (PDT) On Mon, Sep 25, 2023 at 01:17:04PM -0700, Yosry Ahmed wrote: > On Tue, Sep 19, 2023 at 10:14 AM Nhat Pham wrote: > > + is_empty = false; > > + } > > + zswap_pool_put(pool); > > + > > + if (is_empty) > > + return -EINVAL; > > + if (shrunk) > > + return 0; > > + return -EAGAIN; > > } > > > > static void shrink_worker(struct work_struct *w) > > { > > struct zswap_pool *pool = container_of(w, typeof(*pool), > > shrink_work); > > - int ret, failures = 0; > > + int ret, failures = 0, memcg_selection_failures = 0; > > > > + /* global reclaim will select cgroup in a round-robin fashion. */ > > do { > > - ret = zswap_reclaim_entry(pool); > > + /* previous next_shrink has become a zombie - restart from the top */ > > Do we skip zombies because all zswap entries are reparented with the objcg? > > If yes, why do we restart from the top instead of just skipping them? > memcgs after a zombie will not be reachable now IIUC. > > Also, why explicitly check for zombies instead of having > shrink_memcg() just skip memcgs with no zswap entries? The logic is > slightly complicated. I think this might actually be a leftover from the initial plan to do partial walks without holding on to a reference to the last scanned css. Similar to mem_cgroup_iter() does with the reclaim cookie - if a dead cgroup is encountered and we lose the tree position, restart. But now the code actually holds a reference, so I agree the zombie thing should just be removed.