From patchwork Mon Sep 12 05:37:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 12973260 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 D409BECAAA1 for ; Mon, 12 Sep 2022 05:38:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B3508D0003; Mon, 12 Sep 2022 01:38:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 564228D0001; Mon, 12 Sep 2022 01:38:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42B108D0003; Mon, 12 Sep 2022 01:38:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 31D238D0001 for ; Mon, 12 Sep 2022 01:38:09 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F423F40200 for ; Mon, 12 Sep 2022 05:38:08 +0000 (UTC) X-FDA: 79902327498.31.3C4E896 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf06.hostedemail.com (Postfix) with ESMTP id B130518007F for ; Mon, 12 Sep 2022 05:38:08 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id o23so5660299pji.4 for ; Sun, 11 Sep 2022 22:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=FCDrifC5IjqijXV6e18komh4Y6rdr6j1i7EyaPa4Jrk=; b=bVjPF3LkmzOlL6cee9+hacmXazQaezgxu5kP6ipASsZxIcTk0xHjXhEMuNcEfCGVLn vr5sqviyzogt6mDgzl2GyKRn4JAHUGz3gGg7emJm4+FDPF3EMDrNeJ04WrY2kAjVoDe0 /CzDjEVEknJKMb5w058tO0x6UCfS4kkaCoFTM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=FCDrifC5IjqijXV6e18komh4Y6rdr6j1i7EyaPa4Jrk=; b=MYkscVGcw49AiLVEHFi0U2c94he/pC6mhtYmfSXhzwLC0gUpyw+Y5hZ6nyFZs0wt4G ODYNHlRZjityOnioQd9VpnMn0omhy14I3krONJXLAZwIuwHiYPGD/6vfBS58H8k8sgZ0 fSuBoo1x9UD8IG8l3mO4gma7ESQzWsP/rQp7EKxOL9b2KM5pG5wuLpKJFZQGttIM8wdD NFQ/o5A6cfzwh7BmIa2URqSZDWqGKslV1ejCHd1x6rWa5FWqYQlC7pV85PfJkl7av8Uj ANg3ifqT0WfMErK/Lnm7Keqd3SlkbCAMNmxp41wqK4kAaaR3qMU3Q9PHWi4gG4CeRq11 BWjA== X-Gm-Message-State: ACgBeo3IJIQpoHdJRoZJy1HyMgmTe3WSYgfEFl8ZF2mS9Z5jQuAhcnWy PxQBTEgF1OtK82+wVwiSlekjNw== X-Google-Smtp-Source: AA6agR6kCZz836/np5BmThAQGn+2hUV3IT18WiK+bG3WNotRd8Vby6m/1DW7ToKivzMFGNKo3p6duA== X-Received: by 2002:a17:902:f211:b0:178:723:35bb with SMTP id m17-20020a170902f21100b00178072335bbmr14646123plc.43.1662961087539; Sun, 11 Sep 2022 22:38:07 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:e064:d5ac:4dae:9920]) by smtp.gmail.com with ESMTPSA id w4-20020a170902ca0400b00176c0e055f8sm4924431pld.64.2022.09.11.22.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 22:38:06 -0700 (PDT) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Nitin Gupta , Brian Geffon , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCH] zram: do not waste zram_table_entry flags bits Date: Mon, 12 Sep 2022 14:37:55 +0900 Message-Id: <20220912053755.156704-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662961088; 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:references:dkim-signature; bh=FCDrifC5IjqijXV6e18komh4Y6rdr6j1i7EyaPa4Jrk=; b=Q4oVKx3Zg9ZomJJw48AyRi556XHBlKAbCgZ4ibxv1sjk5TzAambI7yAZPBeA13FvpCrqmK XeHGlE++dOJg6XoKhI9RCa/L7BDGmpFZtEoBC5q3CMO41ns69ruf/xdZW5wetj6S3mP7xl KfCfPb5YhjM47K5ELgmtbsf2vKHtDbk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=bVjPF3Lk; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf06.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.49 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662961088; a=rsa-sha256; cv=none; b=dH7+sXDhyL6tiDZ0ZXL0yf+KZSuKSGzlAsWI0kT3Ru+DtME/59j3v4BkU1msnzctf2Y2I9 cHutl1HV+5XgzTm1dKVBMIGgeyrBKRAePw6a+SSrxk7JrEr/236hMxQcmhYTV32XZVRFcF fwzJlXhJ4fbbo5w8a59e2wGrkDlvpf8= X-Rspam-User: X-Stat-Signature: xwt93o6dytaq9u7s7tgrxgg3nbg65xmh X-Rspamd-Queue-Id: B130518007F Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=bVjPF3Lk; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf06.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.49 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org X-Rspamd-Server: rspam12 X-HE-Tag: 1662961088-690341 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: zram_table_entry::flags stores object size in the lower bits and zram pageflags in the upper bits. However, for some reason, we use 24 lower bits, while maximum zram object size is PAGE_SIZE, which requires PAGE_SHIFT bits (up to 16 on arm64). This wastes 24 - PAGE_SHIFT bits that we can use for additional zram pageflags instead. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index b4eecef2a11f..138be8326866 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h @@ -30,16 +30,13 @@ /* - * The lower ZRAM_FLAG_SHIFT bits of table.flags is for - * object size (excluding header), the higher bits is for - * zram_pageflags. - * - * zram is mainly used for memory efficiency so we want to keep memory - * footprint small so we can squeeze size and flags into a field. + * ZRAM is mainly used for memory efficiency so we want to keep memory + * footprint small and thus squeeze size and flags into a flags member. * The lower ZRAM_FLAG_SHIFT bits is for object size (excluding header), - * the higher bits is for zram_pageflags. + * which cannot be larger than PAGE_SIZE (requiring PAGE_SHIFT bits), + * the higher bits are for zram_pageflags. */ -#define ZRAM_FLAG_SHIFT 24 +#define ZRAM_FLAG_SHIFT (PAGE_SHIFT + 1) /* Flags for zram pages (table[page_no].flags) */ enum zram_pageflags {