From patchwork Fri Jan 7 02:17:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CGEL X-Patchwork-Id: 12706096 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 C74DBC433EF for ; Fri, 7 Jan 2022 02:18:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9B1F6B0074; Thu, 6 Jan 2022 21:17:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C4B006B0075; Thu, 6 Jan 2022 21:17:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B12BF6B0078; Thu, 6 Jan 2022 21:17:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id A39E16B0074 for ; Thu, 6 Jan 2022 21:17:59 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5710C18206D2D for ; Fri, 7 Jan 2022 02:17:59 +0000 (UTC) X-FDA: 79001880678.31.7587DFB Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by imf29.hostedemail.com (Postfix) with ESMTP id EFA8112000B for ; Fri, 7 Jan 2022 02:17:58 +0000 (UTC) Received: by mail-qk1-f169.google.com with SMTP id b85so4622471qkc.1 for ; Thu, 06 Jan 2022 18:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SBYBagvggg03DwKt9otfHsLIPVT6M43LhOwukGYuXUk=; b=Sy/9Uasu+Otq8grGnBaWjIKNca9j5Ulw4E54DZSJU9tQxqJbyIS5Yl3TBt9aVyQl03 SDmI2d6L3aWhErx9yzu5HQQnt+iaCDrGeg9dTsu1Znq7rqGwH8896Jikcw94pVX9T/w/ 47Zvim1y1dNmKoWFwRJ80R+iy2vTtNwZAnKSOzh/xvo4PnAe2LR78mqK011pcjHK8fcd 8bLW1o6f0yP916KYwL3/V58Wk8dFEZeGHVF9wxnQas8g5Rhxi5elgFF9AL0ySncce+0h rEIuIhqrJziFyDvqSM9n7XjCliE+t2nBz0WCe01w3c5BNLwCBdU3IVrEE8mkiJY/Vw3S pDjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SBYBagvggg03DwKt9otfHsLIPVT6M43LhOwukGYuXUk=; b=XDY7zu8FYQo/QT5fi85Y7bmjZvHG7lZDj59rQgD9htK7PxBEsEXaB09x9LNo+LvuY8 45+CHKR1nPQLxS/oPB4JcXTezAre+O3lO6Mf9MrGNChJx9ujhuCz0lJ8duYsWu0Z8Nqp HLy4p3TIXwhiQmpFoRDVu9HX9tragjYkE/yLytT5MHe2eMR3nJR/v5JqcAvB2gYOSLJl 6FmHxHiQx+rqlYoCdvDdGZqwtidxcNlrlovCf8av47mBE7xnZGHXjOTaHwjAiybyxiZ2 lTS5b6iC9jWrUjykyFIKgDK2yjmjEHgobPVazyDSXVCZ/mM9/4+mwsv9ouXBiPv2I5p1 GxXQ== X-Gm-Message-State: AOAM531HvRETkhY2sGHwtYDnulcwdFexyoX5IDcK0rf62eLoIdzjzc7f byFQw/iJnGplRtA4YaBcYGM= X-Google-Smtp-Source: ABdhPJzCmUe2aahWL31EXQn8osBohaFXJD+vj9UD1cu/3qosviYk4/6kjmfOCgNCUI1pwKR0p59aaw== X-Received: by 2002:a05:620a:2208:: with SMTP id m8mr40526762qkh.126.1641521878342; Thu, 06 Jan 2022 18:17:58 -0800 (PST) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id t11sm1092323qkm.96.2022.01.06.18.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 18:17:57 -0800 (PST) From: cgel.zte@gmail.com X-Google-Original-From: deng.changcheng@zte.com.cn To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Changcheng Deng , Zeal Robot Subject: [PATCH] mm/page_alloc.c: Use div64_ul instead of do_div Date: Fri, 7 Jan 2022 02:17:51 +0000 Message-Id: <20220107021751.621522-1-deng.changcheng@zte.com.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: EFA8112000B X-Stat-Signature: 84ged784cait6kmqkoeff1x9cdcu9b47 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Sy/9Uasu"; spf=pass (imf29.hostedemail.com: domain of cgel.zte@gmail.com designates 209.85.222.169 as permitted sender) smtp.mailfrom=cgel.zte@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1641521878-727182 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: From: Changcheng Deng do_div() does a 64-by-32 division. Here the divisor is an unsigned long which on some platforms is 64 bit wide. So use div64_ul instead of do_div to avoid a possible truncation. Reported-by: Zeal Robot Signed-off-by: Changcheng Deng --- mm/page_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8dd6399bafb5..60469b616ac1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8431,7 +8431,7 @@ static void __setup_per_zone_wmarks(void) spin_lock_irqsave(&zone->lock, flags); tmp = (u64)pages_min * zone_managed_pages(zone); - do_div(tmp, lowmem_pages); + tmp = div64_ul(tmp, lowmem_pages); if (is_highmem(zone)) { /* * __GFP_HIGH and PF_MEMALLOC allocations usually don't @@ -8804,7 +8804,7 @@ void *__init alloc_large_system_hash(const char *tablename, /* limit allocation size to 1/16 total memory by default */ if (max == 0) { max = ((unsigned long long)nr_all_pages << PAGE_SHIFT) >> 4; - do_div(max, bucketsize); + max = div64_ul(max, bucketsize); } max = min(max, 0x80000000ULL);