Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4656260rdh; Wed, 29 Nov 2023 07:17:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUUml7A7/q8gVurFc1xQ+ferwfH9s3/zq1ub/U7tWRE0EHc0zKku1EBfyB5iEcwnwGbo23 X-Received: by 2002:a05:6a21:a5a8:b0:18c:3fe8:d8cc with SMTP id gd40-20020a056a21a5a800b0018c3fe8d8ccmr18270274pzc.28.1701271060635; Wed, 29 Nov 2023 07:17:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271060; cv=none; d=google.com; s=arc-20160816; b=l95x6jujpQarut3RIOcMC9rWIFTfiUI82tqRda9DcciRZY79z8YoK0s72QXXVhLgRh L/RiJgAmsuWc4nrXCb5qWP1NBh+0FG+uYoG/drnWwQdMpEUNYAP2+wfEbFXpNZ2rg+5K wBaRha+GXfEaxr+UY3b8DbzRZa+hYXCtFqVXalF62QxD9KGQrTW27fO5nHPzSLuhPCmC lh7l5drvJABRwyQnx0gXdWdWF0zT39hxYVV2rHf0lE1N+QdpGeVuFk4BaVxmZQjShw2m 81vDMZWoeLduPHhJ2gq67Nz/pHA4AD9zpkSbTghbe8/byUA8WLeyOD0ZV7VgljvXWDlJ hH2A== 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=Ki5eAeZpOcI54YbTPSCFwp5UJ2eI9c3pK5uL2lEEtZM=; fh=dnuTZ7lF+HScHO+ErJYG5fxqkNw/sSQkqUZDMo0Tq8Q=; b=uMtyprV9unBH48zuI/0Llczq03ZTvnf/i9oSyJv56O4mTCPbgJJryW5OjEK9L991IO mHHGSulZ+a00gIuz4MzWZtqYsMvkK8yjwOKuJ6yb7g07LV7qOvvmBhgA8LcdRTvbrMnN 7yy01Umgs9p2RyL3fXwp6+tugwErLgcE+lmaZagxN3Vo/8PHoUXDKydQ/NN8i2/CiomS 3Db9WLfO0RflMhFSTsbxyA6tnY2M0fLtgKMcQyZHI+YbO8z/Az2LcFhwDlZD9xJe3yIE PVQJb0vRD/8K0xcs+PPGi0ImDianJ/b9tFigvT7ca7bQw2jjFs+z4E/zw0RS0/yix9kZ V44w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=t45yazmd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k17-20020a056a00135100b006cdd47d2ac8si1235930pfu.79.2023.11.29.07.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:17:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=t45yazmd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id EF8B68040193; Wed, 29 Nov 2023 07:17:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234568AbjK2PRX (ORCPT + 99 others); Wed, 29 Nov 2023 10:17:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232038AbjK2PRV (ORCPT ); Wed, 29 Nov 2023 10:17:21 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBF8FA3 for ; Wed, 29 Nov 2023 07:17:27 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-41cd4cc515fso37925661cf.1 for ; Wed, 29 Nov 2023 07:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1701271047; x=1701875847; darn=vger.kernel.org; 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=Ki5eAeZpOcI54YbTPSCFwp5UJ2eI9c3pK5uL2lEEtZM=; b=t45yazmdyT7D3V75tVpLMivlCMgeR/JvS/+C/lc7BHmzaprkmFWcankS3PQr7flX5U iro9DZmFQLFpz1giKu33Gx3a0hs2o5P0fXJ3nePPDmHNHJBITL4OvksYckJlpZuq6x/t KXpt4mDsz/Men8Xe0f6AnBNSr+ipGBke/yG6hy5keISNVDeIbmnlj0iDfO6k4wEV9XwL tO4AaMXr1vXUfpzmjVkE5JkVyr0ZdvPfDf38HIbti5rcMxqkXLJsocTDGnQU0Yl0KSu2 GyQmwozT25v4QB4gsFDL0PDXLh3atKDMZbJPIKzDVL5prK9VcM1yGRM4LnUwqvYt+3N0 wOAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701271047; x=1701875847; 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=Ki5eAeZpOcI54YbTPSCFwp5UJ2eI9c3pK5uL2lEEtZM=; b=i54IrLZTv7GbA+6IdYYSBw1vUOuo1XE6foYP1t0uFA9mmFq7TJpLRXAzB8ZCiSTPtC Hkqc96AXvbuMhhs18hp5tSqQxstFW3hQKRG8jYqZl/j4gOk7jGAvdDzN7REnnFD24/mq +q4vQBP0+ktYizRfCyIU3m/OXNddwpz79lpYawFa8rKD016Zp5SLG1Ap+ysErXImpPYS niteNllM3DoHZwFSLdXyG3hNGXBmhzfKu9Fx8qYOhFrGjj4iCBpkrvgeQPd1BXoGgXQW 425LX3pv8mivdE2Jht1f5SefHi8HlosPRGnS/N45sHefRTXZBDirk4lqIvKF64S2C1mz Ir7Q== X-Gm-Message-State: AOJu0YwbhbNINFse9XBJ1ZjW4Ion84iKA+wUT/4vdLpR9iz6fVeeOMan /xPi4L3wzIks9UPDCou7EP9Ubg== X-Received: by 2002:ac8:7d12:0:b0:423:792f:d5ca with SMTP id g18-20020ac87d12000000b00423792fd5camr24998108qtb.63.1701271046994; Wed, 29 Nov 2023 07:17:26 -0800 (PST) Received: from localhost (2603-7000-0c01-2716-da5e-d3ff-fee7-26e7.res6.spectrum.com. [2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id ay30-20020a05622a229e00b00423a0d10d4csm4386593qtb.62.2023.11.29.07.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:17:26 -0800 (PST) Date: Wed, 29 Nov 2023 10:17:21 -0500 From: Johannes Weiner To: Nhat Pham Cc: akpm@linux-foundation.org, cerasuolodomenico@gmail.com, yosryahmed@google.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, chrisl@kernel.org, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Subject: Re: [PATCH v7 3/6] zswap: make shrinking memcg-aware Message-ID: <20231129151721.GC135852@cmpxchg.org> References: <20231127234600.2971029-1-nphamcs@gmail.com> <20231127234600.2971029-4-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231127234600.2971029-4-nphamcs@gmail.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:17:38 -0800 (PST) On Mon, Nov 27, 2023 at 03:45:57PM -0800, Nhat Pham wrote: > static void shrink_worker(struct work_struct *w) > { > struct zswap_pool *pool = container_of(w, typeof(*pool), > shrink_work); > + struct mem_cgroup *memcg; > int ret, failures = 0; > > + /* global reclaim will select cgroup in a round-robin fashion. */ > do { > - ret = zswap_reclaim_entry(pool); > - if (ret) { > - zswap_reject_reclaim_fail++; > - if (ret != -EAGAIN) > - break; > + spin_lock(&zswap_pools_lock); > + memcg = pool->next_shrink = > + mem_cgroup_iter_online(NULL, pool->next_shrink, NULL, true); > + > + /* full round trip */ > + if (!memcg) { > + spin_unlock(&zswap_pools_lock); > if (++failures == MAX_RECLAIM_RETRIES) > break; > + > + goto resched; > } > + > + /* > + * Acquire an extra reference to the iterated memcg in case the > + * original reference is dropped by the zswap offlining callback. > + */ > + css_get(&memcg->css); struct mem_cgroup isn't defined when !CONFIG_MEMCG. This needs a mem_cgroup_get() wrapper and a dummy function for no-memcg builds. With that fixed, though, everything else looks good to me: Acked-by: Johannes Weiner