Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35189059rwd; Mon, 10 Jul 2023 04:04:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlGrV2VT1LhQ1VvEkHUyW9s84aQHtoz/ChA7bil7xaisic+p59mRe1XaK2CGYpTUHFy8Gd/q X-Received: by 2002:a05:6a00:198e:b0:66a:48db:8f6a with SMTP id d14-20020a056a00198e00b0066a48db8f6amr14690869pfl.12.1688987053447; Mon, 10 Jul 2023 04:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688987053; cv=none; d=google.com; s=arc-20160816; b=U8MlYN+Z9yoswGGxW58L8AhUq7gUBEMPR2A38rsE+ZSMcWtxW+0oVFzJw1Djhf91g3 STfUEOEL470iQPsD60aPvviFjy9kQNH2qlDiVGaPVORfyUEuRNN3chru1hhSG0z7+3yT pZYC3Xq+KuwZ0phQ4nI944BinYlmoddlHac4/Cd5NzSq03egXgIwO1N/Q0NPx8JIkRJo F8Cu5CVxNWh6dQC3UhVKbi10oqq3REq22vkDyOikv4ES/4SyMw0SINaWVtzaWjVrSS0k tdNWFc6se/0oTLnNPUSgdMVYdFq5FF+/71Myg6hnStIAq0YoYm4kpBDa/nmPyR1SYFpb tzyQ== 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=BgqfV8AxMrOa+ZUfGi45FJ2mmGbR/B2qt4snvYgTU68=; fh=E7QL2Rqn/CjzDY3mLvI97hnIbM9p5BI4HpQOjRc5pkk=; b=O6krs+PS4ILVDztDyNw0A87YxnfgCbfCxPRIckdi3780v4XwvmG/R5SL1wk8yEj7s5 A6m3owkOUjBolnNLn+MKWcVj567/MDNyLB9nK+rBc2V7bZoMOABTJFhoyvEfoviPYMY4 UCbUdrxs0AwHW84rGUcx1132UwNhkb/SwXjoOV0wF23dx8SEdggav5YXxmlHSpMp10+X gh06pL8di/JHSM+0aiK0yz3zUzR5yvM7MjOo4L0qRwJ55/ob5ihrkqkmAgA/3eUJQgMD bBotwCR4fyeuK3R0T/2kqXnD9+Bd7schgwdmC8UFn31N3Bn7AMZMKJsnQgrTGbBmrtVJ BEuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="dI2+m/Ei"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h22-20020a056a00231600b0067f9d269213si9022999pfh.171.2023.07.10.04.04.01; Mon, 10 Jul 2023 04:04:13 -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=@suse.com header.s=susede1 header.b="dI2+m/Ei"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231356AbjGJKwp (ORCPT + 99 others); Mon, 10 Jul 2023 06:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbjGJKwk (ORCPT ); Mon, 10 Jul 2023 06:52:40 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F016518C for ; Mon, 10 Jul 2023 03:52:19 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 734531FEBB; Mon, 10 Jul 2023 10:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1688986338; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BgqfV8AxMrOa+ZUfGi45FJ2mmGbR/B2qt4snvYgTU68=; b=dI2+m/Eif/cqR9elAlggzi63z+6kpGiYIJnpcn8uGHobiw5kkab5A/h/gqdIzfMZqxwDTX ySzUG2zcLd7x/DUn2Mt/ma3GKrjr1KMKGx38ZYK+nbHkFw6T1ER2tg6KO8i4Ay+A1H8lgQ DsWXeeNDO18QNWYrw7Yi5vMpRZzIl6o= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 51ABD1361C; Mon, 10 Jul 2023 10:52:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YsyLEeLiq2RYUAAAMHmgww (envelope-from ); Mon, 10 Jul 2023 10:52:18 +0000 Date: Mon, 10 Jul 2023 12:52:17 +0200 From: Michal Hocko To: Zhongkun He Cc: minchan@kernel.org, senozhatsky@chromium.org, david@redhat.com, yosryahmed@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 2/2] zram: charge the compressed RAM to the page's memcgroup Message-ID: References: <20230707044707.1169285-1-hezhongkun.hzk@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230707044707.1169285-1-hezhongkun.hzk@bytedance.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,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 On Fri 07-07-23 12:47:07, Zhongkun He wrote: [...] > @@ -1692,11 +1725,21 @@ static int zram_recompress(struct zram *zram, u32 index, struct page *page, > > zs_unmap_object(zram->mem_pool, handle_new); > > + /* > + * Recompress will reclaim some memory, so we set the reclaim > + * flag in order to charge comp_len_new successfully. > + */ > + noreclaim_flag = memalloc_noreclaim_save(); > + objcg = zram_get_obj_cgroup(zram, index); > + obj_cgroup_get(objcg); > zram_free_page(zram, index); > + obj_cgroup_charge_zram(objcg, GFP_KERNEL, comp_len_new); AFAICS your obj_cgroup_charge_zram doesn't have gfp argument. Anyway, memalloc_noreclaim_save is an abuse IMHO (the primary purpose of the flag is to prevent recursion into the memory reclaim). Do you really can not perform any memory recalim to trigger to free up some memory if the memcg is at the hard limit boundary? > + zram_set_obj_cgroup(zram, index, objcg); > zram_set_handle(zram, index, handle_new); > zram_set_obj_size(zram, index, comp_len_new); > zram_set_priority(zram, index, prio); > > + memalloc_noreclaim_restore(noreclaim_flag); > atomic64_add(comp_len_new, &zram->stats.compr_data_size); > atomic64_inc(&zram->stats.pages_stored); > -- Michal Hocko SUSE Labs