From patchwork Wed Mar 15 11:31:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A . Shutemov" X-Patchwork-Id: 13175676 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 CBD26C61DA4 for ; Wed, 15 Mar 2023 11:31:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C750D6B0082; Wed, 15 Mar 2023 07:31:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFE1A6B0083; Wed, 15 Mar 2023 07:31:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B3DD6B0085; Wed, 15 Mar 2023 07:31:50 -0400 (EDT) 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 8D3806B0082 for ; Wed, 15 Mar 2023 07:31:50 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4DA57120FDF for ; Wed, 15 Mar 2023 11:31:50 +0000 (UTC) X-FDA: 80570917980.05.F61AD93 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf29.hostedemail.com (Postfix) with ESMTP id 1B3CC120011 for ; Wed, 15 Mar 2023 11:31:46 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ZVMnVxKB; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf29.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.136) smtp.mailfrom=kirill.shutemov@linux.intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678879907; 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=ojvIeEkFwkjIxhoLZbBitZpqyYtExVBxUpzX5dqiNDc=; b=zXB0LCUqDgtMkuc0zZVsneEa4WlaysOSEVniAlJUlaxrBC2j4fyUsDEPeqz0cJoRpWRFWH bvk3+xqOAgzB+BgLIOlANT/fR+Wx5emoKGVbDa2OPVkn/S4ZZuYLNVK4qOgg8S0m8/sTLI G5+ku+902T01dvaybCD9iI48s3fF+7w= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ZVMnVxKB; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf29.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.136) smtp.mailfrom=kirill.shutemov@linux.intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678879907; a=rsa-sha256; cv=none; b=vJVebUz3gblTQ6Nh4jcQcap2X5p3g48XFRfE06C/YDXbVucfWiOxwACUWvLYe58jr8/DJ/ H7dE7hClT9nzUvFNTibaVyLYnmott2ecmFFmGaFiHF7VfJPD8y0z/9YT/bCP881ruGP9Vd Hk+c5Tn+fI7d6cumufiAqy8o28GdDdk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678879907; x=1710415907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AX8fQ9JFCUx8sgKM3jU0DHxltPa90kVlWb8uT8+Z308=; b=ZVMnVxKBDdU/vsgiKbG4x6a670i/L7fG0XAlHqpWwWgySwaHTAqJJyGt RxQteUalliM06i81HgE1SlYMgIkZ9wQ8P81MnGf3R6VAypcnmxK0w1R3b 2kbIG3cNqpEmGuDGcs0+FsDoFCePwLsT0VbjIPSg6g5Nm9chb08uxvKHv M9ZFroJVCVF3E42BoRVBOCDeiWWmw3PjeSAi23/x3uymaKkCxNnMnfwkc sfdaZHODYXS6lDhGzMUO/T5RnWoanaWPg+EBp3euSA5VsRX55PBuNgnnl aD1s2GGIr/v+TnEYXf8IymSnyws2VnQJWowKMZk2NPOxEkxgTOWQkmCVO Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10649"; a="317330274" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="317330274" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 04:31:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10649"; a="925310513" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="925310513" Received: from nopopovi-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.33.48]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 04:31:38 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id AB8FF10CC9D; Wed, 15 Mar 2023 14:31:35 +0300 (+03) From: "Kirill A. Shutemov" To: Andrew Morton , Mel Gorman , Vlastimil Babka , David Hildenbrand Cc: linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , sparclinux@vger.kernel.org, David Miller Subject: [PATCH 01/10] sparc/mm: Fix MAX_ORDER usage in tsb_grow() Date: Wed, 15 Mar 2023 14:31:24 +0300 Message-Id: <20230315113133.11326-2-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315113133.11326-1-kirill.shutemov@linux.intel.com> References: <20230315113133.11326-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1B3CC120011 X-Rspamd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ETJStVW+VPzwswbBiPEo/Z7mrM37xuq5oru/hILHmRqEA48fonypuAHDO9DaaEkDGN6GmiZ8AVYrTBIpi+0meJYYmNvCobVU8mcJhKwT5E4esYfLdOBzuKAOrLngJ59dFu4ydU2bCwerDue2J0VhnSZqmOrc1h4G4eKMVtusKUaVK+9DVe35l7+xq0wbeP06lpOspu8MlyZYQMe3HEyYYrBoywtU1WMToLrjpfogEIkAJH/dp0JUmyY0cr9jUjRrukbL3TxwuW3/x+rVo8krc71q4fOB+xo7D3r+NGK09rduoSa0Bz9QljjIYDr5njpmCa 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: MAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1. Fix MAX_ORDER usage in tsb_grow(). Signed-off-by: Kirill A. Shutemov Cc: sparclinux@vger.kernel.org Cc: David Miller Reviewed-by: Mike Kravetz Acked-by: Mike Rapoport (IBM) Acked-by: Vlastimil Babka --- arch/sparc/mm/tsb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c index 912205787161..dba8dffe2113 100644 --- a/arch/sparc/mm/tsb.c +++ b/arch/sparc/mm/tsb.c @@ -402,8 +402,8 @@ void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long rss) unsigned long new_rss_limit; gfp_t gfp_flags; - if (max_tsb_size > (PAGE_SIZE << MAX_ORDER)) - max_tsb_size = (PAGE_SIZE << MAX_ORDER); + if (max_tsb_size > (PAGE_SIZE << (MAX_ORDER - 1))) + max_tsb_size = (PAGE_SIZE << (MAX_ORDER - 1)); new_cache_index = 0; for (new_size = 8192; new_size < max_tsb_size; new_size <<= 1UL) {