Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3919861rwe; Mon, 17 Apr 2023 05:40:59 -0700 (PDT) X-Google-Smtp-Source: AKy350arUzVGwjQr8BLwpLt7n7T6M/KZ1qogf3Fjhbarqb8m4NXg7MWZboOB3SRA1BtfHHnhEAfS X-Received: by 2002:a17:902:e846:b0:1a6:9f09:866d with SMTP id t6-20020a170902e84600b001a69f09866dmr16020506plg.61.1681735259060; Mon, 17 Apr 2023 05:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681735259; cv=none; d=google.com; s=arc-20160816; b=wZuHT9UqUoy4X7SoSoA/t3/ODjcnuAwVgHPk2PjzZU/qWo4fQFby1MJ3TcfH+a+h+D m1vcZMQSB4Emjy8I1b5trBFmqF9cmRmuqs0aOk80ddL+useQbs7hNzm0lY8F9Adty3Wf 4MWSH5ItUswF1D4+hnb/3znNbZyB9nAIOKEg2b7IXOPECSePstppIFDUll6jWjXrDQUR 5qhElO6WNdazAPQi7gM2cpHDe0Adp/f9FW3+FDFeX+zx4k0F1DqUWJAKY7K9xsVEepkQ eL9sMAjzNDGq8kdA989j4dKQYeiwRUDCrxqVmZRlaygciusZSdMcvAOS9pBzJ00qSIes pOFQ== 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=vie4whHHPmibdiBKTG0fY7db5Iv/a7XJkSahv5+UhFk=; b=m4zbWlItaXlUwWBtF2M3/gHZNPFYz/2fsl9qg/SddDsywRbvf7mGNfesBz0/980PfK 9KghY95AKrZx0/0f9+joo71ZuC2CdJbEF/3/k9Vl304VhxFMAcxFSsAMDzMTq5t/SEbm hkowHgZwlM16BIJ5HkupYx0OI95tK3IoOzTrlPRR4aiFMO5UBYL18G9xCyWMEt/Sp0ry uciTNxc6kFuveXPoyLYtIYjhFg0T4oKbg4F/N+vraLUdyly5E0ZChU5ZA83N3f0nBKcJ y8SJQKaaUWCvgrNuRSKUdz1r352EOwAOHrZeRaWhQH6iUONAkhthXnC9adwQe1Akz26n 1IhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="HF/7DG2n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix18-20020a170902f81200b001a6dc4f4a79si2273341plb.140.2023.04.17.05.40.46; Mon, 17 Apr 2023 05:40:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="HF/7DG2n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230516AbjDQMiP (ORCPT + 99 others); Mon, 17 Apr 2023 08:38:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbjDQMiN (ORCPT ); Mon, 17 Apr 2023 08:38:13 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AC6B212F for ; Mon, 17 Apr 2023 05:37:47 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id b2-20020a17090a6e0200b002470b249e59so15089732pjk.4 for ; Mon, 17 Apr 2023 05:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681735064; x=1684327064; 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=vie4whHHPmibdiBKTG0fY7db5Iv/a7XJkSahv5+UhFk=; b=HF/7DG2n1EMT2xuofihIKJwY3AgaoLvNbmm9LAh7A3lIqLAYThD2zLU9zOBOIFpFoF RXooN2MahML4yoGupZdv0xpFFR06vhAsdj7+aDclEylSmHRkv48RF4ZfvRMN/dp5bcWg znxgy5WkZ9glu+iWumCVabVquQgOe9RG3NBjc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681735064; x=1684327064; 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=vie4whHHPmibdiBKTG0fY7db5Iv/a7XJkSahv5+UhFk=; b=B9LOQhon6CnMTgdN+TfWvWOYbc8NidAuEm/mNzzyO3J9HgA+P4ViTia4flyKsuKwPz t5eJiGdLCDfcFVkUFo/XXmQwGOvZv4p6sUrvkPu6oUauw8uv5JiB4S8m09rZUY6fHNE5 jO80cgzTHHI+okl/L3JumxMuXgzCIBUL4obbhPTAAtJf2E4xoulWe8FMo6dqFJ0YuW0B XUdn3X0PKks/KY2VHI3x3tl+zrYvZYbvRiwXwUd/XuOJvKZNoqMy2VsD1G4lf4mqNboI QqzC85+Dtl9rUzLNWGFCiGirv4XkGdnHxNVyD+pz2wPdWXuljyKFhhmehIdfPBnyn0Rg ttJQ== X-Gm-Message-State: AAQBX9dYtZIKtDMbBVb0HapbuWfso06JMHThh2i96eYvDBuKKiEJd06i 8TluxE41dSIqfT+cDIdICPWiOw== X-Received: by 2002:a17:902:aa84:b0:1a6:7fae:3a28 with SMTP id d4-20020a170902aa8400b001a67fae3a28mr11736865plr.42.1681735063984; Mon, 17 Apr 2023 05:37:43 -0700 (PDT) Received: from google.com (KD124209188001.ppp-bb.dion.ne.jp. [124.209.188.1]) by smtp.gmail.com with ESMTPSA id w7-20020a170902904700b001a25d7d1fbcsm7594893plz.38.2023.04.17.05.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 05:37:43 -0700 (PDT) Date: Mon, 17 Apr 2023 21:37:40 +0900 From: Sergey Senozhatsky To: Yosry Ahmed Cc: Sergey Senozhatsky , Minchan Kim , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] zsmalloc: allow only one active pool compaction context Message-ID: <20230417123740.GP25053@google.com> References: <20230417110259.1737315-1-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Hi, On (23/04/17 04:53), Yosry Ahmed wrote: > > Introduce pool compaction mutex and permit only one compaction > > context at a time. > > I am not sure what's the best practice here, but if the only use of > the mutex is a trylock, do we need a mutex here? It seems like a > simple atomic would do the trick. Perhaps something like: > > static atomic_t ongoing_compaction = ATOMIC_INIT(0); > ... > if (atomic_xchg(&ongoing_compaction, 1)) > return; > .... > atomic_set(&ongoing_compaction, 0); Looks good to me. Will switch to atomic_t in v2.