From patchwork Thu Jan 12 07:14:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13097546 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 29A51C54EBD for ; Thu, 12 Jan 2023 07:15:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39CA88E0002; Thu, 12 Jan 2023 02:15:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 34C1C8E0001; Thu, 12 Jan 2023 02:15:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 213B08E0002; Thu, 12 Jan 2023 02:15:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 10FCA8E0001 for ; Thu, 12 Jan 2023 02:15:36 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C6EAFC0146 for ; Thu, 12 Jan 2023 07:15:35 +0000 (UTC) X-FDA: 80345286630.21.533B562 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf24.hostedemail.com (Postfix) with ESMTP id A437D180009 for ; Thu, 12 Jan 2023 07:15:33 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Z8qfZubx; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf24.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.180 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=1673507733; 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=WNSLlROnJSkgN15DCmptn3Khdtb1/dRVR5mfe/1h2ik=; b=sVFLLoOgP4aZAj07EhraghY+HXUJWVRT7p8JkQb/yfQqX/26gVxIDdz1Wlcj3zO7IeHts1 CaD3PJ+hrBhYbVd5cMEqnB1CptkG394LKYguus9tXy/52vJ7L+CJrt75JFn99JBcsLc+0M O7zoDioEAW3kcSajJkmW3zkFd/1nLM0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Z8qfZubx; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf24.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.180 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673507733; a=rsa-sha256; cv=none; b=Ewej0MkRnANZju9dZpyGRvnZrwXdSNHIG3aRKM/Cz3sN7iCYdaar+ezD9CxkFuSi9SZGhk /eUjd+LN2Dq3nb1N0SoYtY7Ewia/qQ5K1+GChMAzSSXkE3XXccfiZSWF0Ue4esUOQ+HNpa ivZIpj0apnFakQtPhd8RrWqsrRqt0wY= Received: by mail-pg1-f180.google.com with SMTP id s67so12180620pgs.3 for ; Wed, 11 Jan 2023 23:15:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=WNSLlROnJSkgN15DCmptn3Khdtb1/dRVR5mfe/1h2ik=; b=Z8qfZubx+z0IoTKIQznPAOA8axWTCiUQjRph76J7wUSbIXNIslIKoy5wj2gLJeKTSi 0hPiHkN8wya06J1BruCbHoIa7X4yOxvsavyQEN224atMg+hZT9HGV1DkqypbfIZOaYto 68LxBOmug8+Ikm8iZTKVk0TsvlsdfAP6LggHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=WNSLlROnJSkgN15DCmptn3Khdtb1/dRVR5mfe/1h2ik=; b=WWDQc4eL80n+XivgMXl5i1m/4z5DTYzfdxLX/mSa9vNEZuLAjALjjd1rO3WFgt6aTD /NlTzn1tB/Pj+Azw6lfkjYlp0gW1gGZMDjAC/sONGCmfS1wD+XWNYWdmkxfBEduv7+tE K4UvugMn37HJg7/WXDZAw8ntfalh5auT9jCBr/xydY4G2bQNgGB1GMZdiUD7dmEFLOea k+/0JUjY6y17AA6QlwnNxQWAsfsHAq0CXQjaUAMtEpMXDp/cvn6C10RypyuUEWq6v9NW hZQR9ca/IHdgOlH7/3xDSRz8gY6hGwVS/fhV+A3wfID/NFpLhtmiav+DnGdStWr5F+HK TQlQ== X-Gm-Message-State: AFqh2kojsOjlZcXNnbrHFsAURrl8kXRG9CQcjkh1e+ItA2NzuzQAQCsr AmwsiadzbSvF6Vs6tk2K906O+w== X-Google-Smtp-Source: AMrXdXt4o1GyXaKZeMG0Y9nYlABViwtAaD563g9m6wYHD78QqRVryTGKnua/YhCQ+8vRhNHhT6FXqw== X-Received: by 2002:aa7:9436:0:b0:589:78:80cd with SMTP id y22-20020aa79436000000b00589007880cdmr12972397pfo.8.1673507732355; Wed, 11 Jan 2023 23:15:32 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:59e5:ea10:b191:6fbd]) by smtp.gmail.com with ESMTPSA id e26-20020aa7981a000000b00585cb0efebbsm600847pfl.175.2023.01.11.23.15.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 23:15:31 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky , kernel test robot Subject: [PATCH] zsmalloc: turn chain size config option into UL constant Date: Thu, 12 Jan 2023 16:14:43 +0900 Message-Id: <20230112071443.1933880-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: A437D180009 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: setmeryjw4e86tjm7xm57f596hz3j7k3 X-HE-Tag: 1673507733-766497 X-HE-Meta: U2FsdGVkX1881CQOSEUpiPwK6QmgQzTqpNpgCmbB8VJqP/vQs+ltU0ErILoYjMOEc5LLG06Wl5FsnADNB86oUXzPQdUzkUGxkea9CU7noUmw/rpm9C5vmguIPdStLRPxcv1R9rgmQUqvuajrlrnWqmc8YMrSAGWzoGEXjeNb+WWGE+4WdDzGHkRyHhS7dqMs7jW0b7x64Lf9LlubyD1eGK7IEvtGA5xB0QlfHH5UObq/WDP7vc+fAKzaQUpmm386kSqht2qVqk39xCVKCU9i5mqDXsWyEEtnfUX/svWdn90eJ5UmHEixvOrMU04U6ylXPR45z0Eq96H5BK8+GWrlxr9JpVHzN4VSmail9eteN2sMDf+1MXFNQ6cAMfeOJHNSNM1gmeJHSh5aLL5L1ppvsyrZ+7VNFd1ojk4hjexc02ElzbaK1BmKrGBiWrV/YQc9Iq4qP9+4P5dFtwaNKGBAK/g9EklCEPObK1A2nImK0sDgFO55vdndaCfPeXo3moPU5vZzV1b9IJE3DJ+rsZyO3Krg4ookoq+BbaObIbGmxuxfvmXviAT3+g2tV385wWN3g3EBAZ7ODVOoj2L4Sz4Vf3mL2xep6WsgdJDqIwNpEhj8Ds6x3DAXh+aSzRo1gir6f+dSCMjvxGqkopgMmtMVms3w68b0ME8DUFxBj8oFnJHX7RWo6tJ7SVuDqpsmIOuUG7GtI5syV7aWZWUPYfqKaq6HcHkpFCFFP6MMh2mxl8luIbNZoiQpbiQRhc4ALiU1FS0BmwvXk+e0QnD6KK3FuY2r5Osx7MtM5X8+I51Ej/7CzqSe3ndR9905qRIVPCq2F9jyTzbet0wQ2pFuzJ1UPdmWogRW36rJFVwhTnARIpjF/X9ajF3DneJ1g7hBuiPMtkAFN7sKT8pqQY04E/pKqLdESmN0E3yySPU8AnWijzxhFi6DlKjPUofPm2I7sIIZwufTEWW2UfunCzgX7I1 MbC+7+MK npjw6D838/G/LSHiV6dfrHRhL9DalJ1/REZiBabCbPFs1PNWBXTHifldeq1S4n8ZoPxMVSIMUAKOdw0EON9lnSXToqsLUj+T1zqcW0RLBK793cu5X1Z3D6p6bKNG+6332At6W 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: This fixes >> mm/zsmalloc.c:122:59: warning: right shift count >= width of type [-Wshift-count-overflow] and >> mm/zsmalloc.c:224:28: error: variably modified 'size_class' at file scope 224 | struct size_class *size_class[ZS_SIZE_CLASSES]; Reported-by: kernel test robot Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index febfe86d0b1b..290053e648b0 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -133,9 +133,12 @@ #define MAGIC_VAL_BITS 8 #define MAX(a, b) ((a) >= (b) ? (a) : (b)) + +#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(CONFIG_ZSMALLOC_CHAIN_SIZE, UL)) + /* ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN */ #define ZS_MIN_ALLOC_SIZE \ - MAX(32, (CONFIG_ZSMALLOC_CHAIN_SIZE << PAGE_SHIFT >> OBJ_INDEX_BITS)) + MAX(32, (ZS_MAX_PAGES_PER_ZSPAGE << PAGE_SHIFT >> OBJ_INDEX_BITS)) /* each chunk includes extra space to keep handle */ #define ZS_MAX_ALLOC_SIZE PAGE_SIZE @@ -1119,7 +1122,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, gfp_t gfp) { int i; - struct page *pages[CONFIG_ZSMALLOC_CHAIN_SIZE]; + struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE]; struct zspage *zspage = cache_alloc_zspage(pool, gfp); if (!zspage) @@ -1986,7 +1989,7 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, struct page *newpage, struct page *oldpage) { struct page *page; - struct page *pages[CONFIG_ZSMALLOC_CHAIN_SIZE] = {NULL, }; + struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE] = {NULL, }; int idx = 0; page = get_first_page(zspage); @@ -2366,7 +2369,7 @@ static int calculate_zspage_chain_size(int class_size) if (is_power_of_2(class_size)) return chain_size; - for (i = 1; i <= CONFIG_ZSMALLOC_CHAIN_SIZE; i++) { + for (i = 1; i <= ZS_MAX_PAGES_PER_ZSPAGE; i++) { int waste; waste = (i * PAGE_SIZE) % class_size;