From patchwork Wed Dec 18 06:34:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13913085 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 8DB31E77183 for ; Wed, 18 Dec 2024 06:35:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 210DA6B0089; Wed, 18 Dec 2024 01:35:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C0466B008A; Wed, 18 Dec 2024 01:35:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 013776B008C; Wed, 18 Dec 2024 01:35:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D31EE6B0089 for ; Wed, 18 Dec 2024 01:35:30 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 50A3C160BBA for ; Wed, 18 Dec 2024 06:35:30 +0000 (UTC) X-FDA: 82907117412.23.4876ABC Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf14.hostedemail.com (Postfix) with ESMTP id A4CBD100005 for ; Wed, 18 Dec 2024 06:34:53 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=CqM4iqg0; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf14.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.173 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734503713; a=rsa-sha256; cv=none; b=zGz71MXElCOSqvERhVNQoX8RnRYx4aK8cTmR4YnTO0WMjLY3Nzzhy+71m62mWStv37ljOA sOqZLmMc/hSO2OYdHvVKpmmbSwwnWGm2TKOW9tu24VxZrEiio32nItpN3ezw9hPOVCXwBY trot6EkUdESAEFfwRMIl1nFwZdumVWo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=CqM4iqg0; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf14.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.173 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734503713; 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=1lsNLWZe1xx8LIy2DkJ6EwI7DqhKpPjMJ1gyizR1Gbo=; b=xu57j3Rpmrih9H61YM4ZXnV31Ti0APYDB2100A7+RZ+PkyvVBRZAE8/NX3/vK8PlMaZu8A FeaKKMF7BxgHXpcFTM2EtFYHJa/7Geux8W3qgqJ3SvaHvoz9Fxj5XRktS2M6DC2MEE3UoR GGwyITDFLmZZQCwAJU2yU79UvJcRzOg= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-218c8aca5f1so19808685ad.0 for ; Tue, 17 Dec 2024 22:35:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1734503727; x=1735108527; 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=1lsNLWZe1xx8LIy2DkJ6EwI7DqhKpPjMJ1gyizR1Gbo=; b=CqM4iqg0kJeZb+5zTR1X7KIfDKaruduWIMsvbbHJsrej2GjXDP6e1b2RcAK4YJRKvi iAxQHNv5p4670LWXB92ZuoUbDXbFOTUGsrfvN1GkgEaNVHoesBent5hI2q+tLIWe1Wby e9xyx3hMzbCxUuvIPlwNsY2dQ4nS2LOViglu4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734503727; x=1735108527; 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=1lsNLWZe1xx8LIy2DkJ6EwI7DqhKpPjMJ1gyizR1Gbo=; b=BvPXbCB7MGA994Z0vEsVR79rFK3UUraz90vJSExfyJ4mgE33yYrnAtpOa+Kf9xqonD mi8LCLCZpC86S91I7l9SoTOODDWeAO/kQUp6wUFFu47KHy6z7hHZXRzq0tAsxI+oMqCa Ju+bO4hrFQlB6E2iE6Kam8iZIXaImkVPVuavHSYsLmPoMYWzv3zeenwanBDMQi9hqt0O /06F5UfEOuX9U+1O27/PrbQ6PuIw3tICwRcHpsSGa6bZVgZ1s6UjwBHsZFKLuUyRbrET 9wIs0kWBozpYn1SKrEBdPPd9nKtwAL6wrZRDhraf7IP6iENwXKJkzuJfVynCh06r5qbQ Trkg== X-Forwarded-Encrypted: i=1; AJvYcCW5MLFwp8fXS2sf2nMQhRxpEhWu944tD3dbHS+BTr8vdCpeQD0oloOUaJVVa2MGX8+ACd+qrK6dMA==@kvack.org X-Gm-Message-State: AOJu0YzyVbj8cl9X1K5zTnnpBqaktO14lPMzZTndMdWNJXc++mERmGml 1GODxuNTxLZaXxGzXV/jD/iWIcTmtmIwwB7dX34e1KWCHi4T1+XDF1IugqbFOg== X-Gm-Gg: ASbGncuaX/aO9CExJX2RduyX9HGGJCmCtExoAhNLx74+qK/DCgbpRNBM7QV/Y0aFPjM q43qz4gaifD3QLlwLPbeqKULgf8C+zbWzso4XFFeEYWHDOmtOebhlNrGneQr8GsTSJ/71ir91r2 YDbvBnRle6Z2pddrXHNIh6HCdc3oYwuz4LU5s1dwFsBx6t4ZiKNOUtTAnef4It/+FcomjQYbK7p NpWEjbREgD1TvobS5EnenG9HMcr573v7ZzjAEJVS7feK2QLtd0V7vVprOg= X-Google-Smtp-Source: AGHT+IGtvXF84vSzKEt9nvcRn17lafPxKZcVbWSXwCigI3N+2LoaMAbFgPOkqbnj99UeaG1XnEyJIA== X-Received: by 2002:a17:903:2447:b0:216:725c:a12c with SMTP id d9443c01a7336-218d6fd7926mr23537805ad.9.1734503727216; Tue, 17 Dec 2024 22:35:27 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:3bcc:36cc:b9fe:9379]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2f2ed62cddbsm656772a91.15.2024.12.17.22.35.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Dec 2024 22:35:26 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton Cc: Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv2 2/7] zram: remove entry element member Date: Wed, 18 Dec 2024 15:34:19 +0900 Message-ID: <20241218063513.297475-3-senozhatsky@chromium.org> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20241218063513.297475-1-senozhatsky@chromium.org> References: <20241218063513.297475-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A4CBD100005 X-Stat-Signature: p7oka54wggsbot96gsbo96xj4w9fq8cs X-HE-Tag: 1734503693-309683 X-HE-Meta: U2FsdGVkX1+frescl5lR5jHJX9lcZgXChbkBQs7Zm/TChxdIWiABNyX3EqSjHXZ5vHpm/1YUvJ1L2AHGeEkapDEmAAv3FOctqs98b63jqXO++bXvbcvCM1F47sdO/cKgmugF1j4d4DgQvWLuR0UdWK7HdT7f0Y4FhK9XIblH47LbPjgxk5kllBDSlTltgT9AVzaUSmaSL+c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, spamicity=0.039701, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Element is in the same anon union as handle and hence holds the same value, which makes code below sort of confusing handle = zram_get_handle() if (!handle) element = zram_get_element() Element doesn't really simplify the code, let's just remove it. We already re-purpose handle to store the block id a written back page. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 23 +++++------------------ drivers/block/zram/zram_drv.h | 5 +---- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index cda0f3fd4058..8c71ddd17024 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -112,17 +112,6 @@ static void zram_clear_flag(struct zram *zram, u32 index, zram->table[index].flags &= ~BIT(flag); } -static inline void zram_set_element(struct zram *zram, u32 index, - unsigned long element) -{ - zram->table[index].element = element; -} - -static unsigned long zram_get_element(struct zram *zram, u32 index) -{ - return zram->table[index].element; -} - static size_t zram_get_obj_size(struct zram *zram, u32 index) { return zram->table[index].flags & (BIT(ZRAM_FLAG_SHIFT) - 1); @@ -879,7 +868,7 @@ static ssize_t writeback_store(struct device *dev, zram_free_page(zram, index); zram_set_flag(zram, index, ZRAM_WB); - zram_set_element(zram, index, blk_idx); + zram_set_handle(zram, index, blk_idx); blk_idx = 0; atomic64_inc(&zram->stats.pages_stored); spin_lock(&zram->wb_limit_lock); @@ -1504,7 +1493,7 @@ static void zram_free_page(struct zram *zram, size_t index) if (zram_test_flag(zram, index, ZRAM_WB)) { zram_clear_flag(zram, index, ZRAM_WB); - free_block_bdev(zram, zram_get_element(zram, index)); + free_block_bdev(zram, zram_get_handle(zram, index)); goto out; } @@ -1548,12 +1537,10 @@ static int zram_read_from_zspool(struct zram *zram, struct page *page, handle = zram_get_handle(zram, index); if (!handle || zram_test_flag(zram, index, ZRAM_SAME)) { - unsigned long value; void *mem; - value = handle ? zram_get_element(zram, index) : 0; mem = kmap_local_page(page); - zram_fill_page(mem, PAGE_SIZE, value); + zram_fill_page(mem, PAGE_SIZE, handle); kunmap_local(mem); return 0; } @@ -1599,7 +1586,7 @@ static int zram_read_page(struct zram *zram, struct page *page, u32 index, */ zram_slot_unlock(zram, index); - ret = read_from_bdev(zram, page, zram_get_element(zram, index), + ret = read_from_bdev(zram, page, zram_get_handle(zram, index), parent); } @@ -1750,7 +1737,7 @@ static int zram_write_page(struct zram *zram, struct page *page, u32 index) if (flags) { zram_set_flag(zram, index, flags); - zram_set_element(zram, index, element); + zram_set_handle(zram, index, element); } else { zram_set_handle(zram, index, handle); zram_set_obj_size(zram, index, comp_len); diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index 134be414e210..db78d7c01b9a 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h @@ -62,10 +62,7 @@ enum zram_pageflags { /* Allocated for each disk page */ struct zram_table_entry { - union { - unsigned long handle; - unsigned long element; - }; + unsigned long handle; unsigned int flags; spinlock_t lock; #ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME