From patchwork Thu Jan 30 11:10:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13954488 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 C6C44C0218A for ; Thu, 30 Jan 2025 11:12:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 572BE280283; Thu, 30 Jan 2025 06:12:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FB532800D6; Thu, 30 Jan 2025 06:12:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35257280283; Thu, 30 Jan 2025 06:12:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 854432800D6 for ; Thu, 30 Jan 2025 06:12:22 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F1C28C0FAC for ; Thu, 30 Jan 2025 11:12:04 +0000 (UTC) X-FDA: 83063853810.01.9ABF556 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf30.hostedemail.com (Postfix) with ESMTP id 23C2380009 for ; Thu, 30 Jan 2025 11:12:02 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=b+yu9dfD; spf=pass (imf30.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.171 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738235523; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=M1+IQlt9pyJwpRT7WcoMT+zWDZRWfxL4uFL06pInV4g=; b=5Zbiu7F45jGknCuylHPbtgCwbLwS5Z0pkF7TCDMEZCG2OC7v7ptrVUMiDZV65VwWV9HFqx +ywhtlEWyLwgW+49NXTaLukdDy1acF45602w21BVobPP4rkjO5PboG9exNxq9BgpCc1sUM doZ5ihpuVA05+ivWsrnzBTUlR97RJrE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738235523; a=rsa-sha256; cv=none; b=JOkOPhB18uzkznWoJ+PMrR0/TO1j2CTopI/AsVWj6pi8wnfCJAEIJp1eg+oPIg4SVRjOP8 hHc17fFMCtcW2Gb4Y8ixc4xg1Xg01qYtl6x7AotnZlMvm96hl8zX8T+eqTtxJzJHMB/drw OxtU6ut1DwX8SXD59m/K3dCRM3X2iPQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=b+yu9dfD; spf=pass (imf30.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.171 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-216395e151bso7203225ad.0 for ; Thu, 30 Jan 2025 03:12:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1738235522; x=1738840322; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M1+IQlt9pyJwpRT7WcoMT+zWDZRWfxL4uFL06pInV4g=; b=b+yu9dfDradCU/rMeJ4teqxLO5Sa10P5C4tBQkzGD7cZ/ys+RfkjwYMnq8dDIarS/P YqiDevI8q0Sz8UgAjqTF2XThmQYR/fQkrIKLEveSZd/m0Xk65kROE4fallnLI5xdncIg IMZmvjfG3ZwGxotJZcpDfXe51AWn1CW6M20js= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738235522; x=1738840322; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M1+IQlt9pyJwpRT7WcoMT+zWDZRWfxL4uFL06pInV4g=; b=BnsoKsysQiT+X9jwff7zxTICJF7gsx2zVO+6+S+5CXvRbfAAviq+swf5q5YiVI2ntI JalqgC4QrEygbpk8O7Qf5nXzorTz4ws8JQRMqEGuhuvHaJgCEWm+7xQq2zxqLuF+O4/i fLFLroaZssSU2SVNOn45lMMF6g86O5sZXffJyLM4DO/s7dlE9qWRqXr1V3uIgr04oZJ+ laN2BJGkeKJCQLE88jZrhmzR8Z5CR+x+GIO0NOenmLpuDSkUNYy4Keb6T5SNFTmglhga vJi0jmPiGdrbLHRPSCgCbYIxppl4vUJyRhCYsf7oUQQZoGGN0tMwSpujGkfL1evZVq9n QBvQ== X-Forwarded-Encrypted: i=1; AJvYcCWua5soWBFxsND7IFQvzAn+CPbRgXp3NTEPb2pVZtIq2W+psMUZXQo8fZ55Lm+IIWEjPt7DbTvjgQ==@kvack.org X-Gm-Message-State: AOJu0Ywc+ditxY7xj7y91H/JemeJ+X07Wr2uqv1Y9Sgre15ALwuXJybu BVB/1YsDnuD+DrO+sfRjYwJpLg6yCWs52Cqvnzl2Ep8BmKCFMeTG66wvFBZOhQ== X-Gm-Gg: ASbGncvRsB6TfBz6bFKVZChrca1s6mE+4hf6PAZt9B9QUmLra1O9v5FASuky71kmC9G 5qqqnX3/khalJbIVHL2v8uy5GZb+Ru37hl3s14fZPKokSvR+exCy4icwjbPKffC2U8bTDNSJB1Q Y+ucjOm9+ah4UW1NDcNJpMDBHjfag1tUcQvyoMfhiLDSlz/KgGT8QzZ/y+TTuSsrNV6Sw0eTOpi 6+V5g3q0nxZ41Srd/ZiCUOf9JaYhI+cKsp0UYHyzhVNslqKykWEoAGs4TlavaJnkg4zRVCiODtd DiUXkSvjlQzD0lkz X-Google-Smtp-Source: AGHT+IEpCpAng/2jtEa7zxIDkv9KC8ilU6auGAeJO2psWZMa0QEO4BHwp4dFoq3oCn6eJDAqgONEiw== X-Received: by 2002:a17:903:2284:b0:215:a808:61cf with SMTP id d9443c01a7336-21de19ca626mr48669045ad.25.1738235521983; Thu, 30 Jan 2025 03:12:01 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:d4ce:e744:f46b:4fb]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-21de3300880sm11526865ad.168.2025.01.30.03.12.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jan 2025 03:12:01 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton Cc: Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv3 10/11] zram: filter out recomp targets based on priority Date: Thu, 30 Jan 2025 20:10:55 +0900 Message-ID: <20250130111105.2861324-11-senozhatsky@chromium.org> X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog In-Reply-To: <20250130111105.2861324-1-senozhatsky@chromium.org> References: <20250130111105.2861324-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Stat-Signature: rsbd9xqcnmg8brmbdba9ww6puuqtgey4 X-Rspamd-Queue-Id: 23C2380009 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1738235522-536786 X-HE-Meta: U2FsdGVkX19B/1Aa07x4ahJ//Kj2z8JIIONZwww2TuiRAvCwQjsvdxGpH2GOgDfVUt3jUyWZHvCWnEhZUKV0/a4faR/JB/HaUU3GFr8nPPnFjhrEuNoNwkVkQhMRmdjF3PShKlJ8s/oMjkg//4v2wXXswMo3Tcq6bFT8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g7EnreQT/MBa80Sv3wSQkQ6OpBC4FLzhmRdZe7j8PoOdG3LefFASlN+cLwwzhznOzIg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Do no select for post processing slots that are already compressed with same or higher priority compression algorithm. This should save some memory, as previously we would still put those entries into corresponding post-processing buckets and filter them out later in recompress_slot(). Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 3e91fd1dcfc7..500d6c8b17fc 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1813,7 +1813,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, #define RECOMPRESS_IDLE (1 << 0) #define RECOMPRESS_HUGE (1 << 1) -static int scan_slots_for_recompress(struct zram *zram, u32 mode, +static int scan_slots_for_recompress(struct zram *zram, u32 mode, u32 prio_max, struct zram_pp_ctl *ctl) { unsigned long nr_pages = zram->disksize >> PAGE_SHIFT; @@ -1845,6 +1845,10 @@ static int scan_slots_for_recompress(struct zram *zram, u32 mode, zram_test_flag(zram, index, ZRAM_INCOMPRESSIBLE)) goto next; + /* Already compressed with same of higher priority */ + if (zram_get_priority(zram, index) + 1 >= prio_max) + goto next; + pps->index = index; place_pp_slot(zram, ctl, pps); pps = NULL; @@ -2134,7 +2138,7 @@ static ssize_t recompress_store(struct device *dev, goto release_init_lock; } - scan_slots_for_recompress(zram, mode, ctl); + scan_slots_for_recompress(zram, mode, prio_max, ctl); ret = len; while ((pps = select_pp_slot(ctl))) {