From patchwork Mon Oct 31 02:14:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13025333 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 614EDFA373D for ; Mon, 31 Oct 2022 02:14:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEEF66B0071; Sun, 30 Oct 2022 22:14:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9F026B0073; Sun, 30 Oct 2022 22:14:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8D676B0074; Sun, 30 Oct 2022 22:14:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 955A26B0071 for ; Sun, 30 Oct 2022 22:14:46 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3DA96AAE69 for ; Mon, 31 Oct 2022 02:14:46 +0000 (UTC) X-FDA: 80079626172.09.A629B31 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf23.hostedemail.com (Postfix) with ESMTP id D173B140008 for ; Mon, 31 Oct 2022 02:14:45 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id k15so1434292pfg.2 for ; Sun, 30 Oct 2022 19:14:45 -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:message-id:reply-to; bh=cOg20qnEayV4nPlpIpR6eCWAzbrV4516eZcvT8U4UVo=; b=I0ejvWcRm2/9CvBT5pCdU+n+MF6tYrR3BL0b4SxQouGOu/vgyoIzYa3RBkhX5sK1cO jiJCgXfJRw2hG5F73KwGb84nmQXHvTOxaPY49NvCdOkw/eUWcycquTOnKQS8vWqU8XBO ad4lZVNVpVGZVZjlV2jiv4zBKpsqVUecOOaAw= 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:message-id :reply-to; bh=cOg20qnEayV4nPlpIpR6eCWAzbrV4516eZcvT8U4UVo=; b=FvCznYzsS+UsL66LnIECNtMM9tWZCK4iMyejTSyHy7QxVmKUiG6goAyLV2LYPSDJiC p/Ectv82CXQ9AkfcAAtifcgBs6kft26bi9h98TEHysT6buElQMI2z03wEjcG2vFb9U2+ NPSrhA/Yb8gxsXRDUBn95hYfAGUAuWSjcAL6f1TPWRXpjheWKLL5V56+5gpq/bXKQ8H3 yE2voWFVFAVpC1y6fqT9Yxmd4KVumWcvk52tIo9jCVJDIJ92zcp7exU775jw6mBduepj gzhObAS81a0chfsGKOvLfKDJW/nu049yDDmxFkCP6QXP69soQDfuVW8IhARLkVh+m9Ef AvlQ== X-Gm-Message-State: ACrzQf0YJSwy7Lv9AhGB3UpPvBK0TfOW7Qc1ojxZ+EAY7UlvUkUuyb+e 97kTYM/UTkSi08CovWU5XxceCw== X-Google-Smtp-Source: AMsMyM7rUVD16GhNPqBdMSFskAkp4rL4S76Ecx1KvcHTAMdeEQaCG9DMEi3RQObY3pgZWQmnsg++Lg== X-Received: by 2002:a63:4517:0:b0:464:4f06:a0f1 with SMTP id s23-20020a634517000000b004644f06a0f1mr10187716pga.509.1667182484401; Sun, 30 Oct 2022 19:14:44 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:7616:afe0:ba6c:96f4]) by smtp.gmail.com with ESMTPSA id g6-20020a625206000000b005633a06ad67sm3266699pfb.64.2022.10.30.19.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Oct 2022 19:14:44 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky , kernel test robot Subject: [PATCH] zsmalloc: use temporary unsigned long for min_alloc_size calculations Date: Mon, 31 Oct 2022 11:14:38 +0900 Message-Id: <20221031021438.376636-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=I0ejvWcR; spf=pass (imf23.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.177 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667182485; a=rsa-sha256; cv=none; b=FOt+YI3s/3YWnMbw1/4ECPAtSAlcFTK6OHgK1Nt4DLh0U9vgpmYN4Xvy4GPdhfWUJ9jYsb 5gLeAMDgD2HS+z2z3r/bqTBK1cuzbevo2DG1I8hpLQod67RFl3WA3dFekUMPjEBrAsDft5 Q1BkGyUhutPSVVzO9zdn1WbCn3okg5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667182485; 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=cOg20qnEayV4nPlpIpR6eCWAzbrV4516eZcvT8U4UVo=; b=08BFB5PlhPNT9d2WDf4TG4hZmHa2fFtYGZzwYWHlBqimkS5Xt0jHS7ObkuvP9V6AEkPsOk FjLFBOoyZdF6YjAtKzvdT6lCrC9GlJ3PUGLmWVm1CGa4TMP25HrwsqdV2ux1SSKJTQ4X9o Ku6vjhyRWmZmhZ3TF0piP8REPpqw8WI= X-Rspam-User: X-Rspamd-Queue-Id: D173B140008 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=I0ejvWcR; spf=pass (imf23.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.177 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Stat-Signature: s73eax8wjjhx88xch8wf9hr74rab4sac X-Rspamd-Server: rspam10 X-HE-Tag: 1667182485-240849 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: kbuild reported the following warning: mm/zsmalloc.c: In function 'zs_create_pool': mm/zsmalloc.c:2220:69: warning: right shift count >= width of type [-Wshift-count-overflow] Use unsigned long temp variable for calculations in zs_create_pool(). Reported-by: kernel test robot Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 0bc9ed1f1a5d..181bfc66249b 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2211,6 +2211,7 @@ struct zs_pool *zs_create_pool(const char *name, u32 max_pages_per_zspage) int i; struct zs_pool *pool; struct size_class *prev_class = NULL; + unsigned long num_pages = max_pages_per_zspage; if (WARN_ON(max_pages_per_zspage < ZS_MIN_PAGES_PER_ZSPAGE || max_pages_per_zspage > ZS_MAX_PAGES_PER_ZSPAGE)) @@ -2221,8 +2222,7 @@ struct zs_pool *zs_create_pool(const char *name, u32 max_pages_per_zspage) return NULL; /* min_alloc_size must be multiple of ZS_ALIGN */ - pool->min_alloc_size = (max_pages_per_zspage << PAGE_SHIFT) >> - OBJ_INDEX_BITS; + pool->min_alloc_size = num_pages << PAGE_SHIFT >> OBJ_INDEX_BITS; pool->min_alloc_size = max(pool->min_alloc_size, ZS_MIN_ALLOC_SIZE); pool->num_size_classes =