Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1541018ybz; Thu, 16 Apr 2020 11:00:09 -0700 (PDT) X-Google-Smtp-Source: APiQypKdJpH6ClGMZOKu7+tZl6wpTniAkFHuGu60SDB8vlFLDxCuX4RA3b9aKFZ4uPYu8cKujVPh X-Received: by 2002:a05:6402:28b:: with SMTP id l11mr25166799edv.156.1587060009588; Thu, 16 Apr 2020 11:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587060009; cv=none; d=google.com; s=arc-20160816; b=JxQTCoZJApifszmljHF2sJGeaP0BZVS4EfEujBR3Q0K6FbR/hMsxH6pEeGST0p2KkX irVMdKNc0aRWYoL2gQLjtch352AAJKXBFM5RfuGWctzs8Pe8lYS5eD1DfNS5+W7PAGv6 hllNiCr/8jOBaf4f4TbUeMHn2KyFL5LVwHgyX70/ObTMU3JpbRG9JI+SVxha3duHSTGy +JcCybbmuaC1d0kFJwZm+CgsMYvgnk8YYq6YWDoRKXCCE/RqSiyUFfqe8AFpf++VbLKW 3rG8l+Df/VtWZl8c+bbXP3a/gL3xnbJywBNH1T3KtErN6VOgCg10lhAbmNdyyrKQw3sR TPoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7TD/jK4l8AYj7m5f9KYA18k1zHlTeEvEQeS3xIZIUAI=; b=VQdsrSfLCJMj1/sRXxr+b6Qz1fvTd4MVex/oQnWcZjyUDhG98SWMInM5Wo1K2z1RXi 0KKDWlS5B0sG+gWawU1MjKyTXJONrYXA90eDPlUwWJCtMBhwzEhnVnSlZ1Xm975oWSm5 c3+sN5QoOIKK9/zJHE6w0I6mMk0SAn605nkuRnhUGSHSqXDkKTSQ/OuWGGs6mX8KG0Nx ZEpMW+onlZfJ023+U1jbK57R9u68tbhyZee9Y60chx8LHqMAJIKBEvrv1NfSGNUu91/U gz4tucJGh3Fn9NybXG/p5GTiLWX02dNF+12yH2SfJfLyD9jxNBPoabQNBFoxfnr4ECdC q9qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E3DSmEWG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si10793563edb.87.2020.04.16.10.59.44; Thu, 16 Apr 2020 11:00:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E3DSmEWG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2897345AbgDPNgi (ORCPT + 99 others); Thu, 16 Apr 2020 09:36:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:39776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2896067AbgDPN3q (ORCPT ); Thu, 16 Apr 2020 09:29:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 41441217D8; Thu, 16 Apr 2020 13:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587043785; bh=nLk72JFj+2vX8XnZrO5sy89nEwKxWMogbtUOdGa0KEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E3DSmEWGvphcXQhabx8mo1GL/PJsxVZrsbBoRrjYEX7tyTQcPZvTsCSd4QfVx7uJE Fy+rZFSog7xbTZUdESX9BnugyXVZO7ztHXGa7kPv9grhxpVpGZ/sfYBvsiF44XS1VD JkKMDtIjglXqiJznYYHfVVf/QZ7EpDbsyjg8eqsQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Duyck , "David S. Miller" , Guenter Roeck Subject: [PATCH 4.19 099/146] mm: Use fixed constant in page_frag_alloc instead of size + 1 Date: Thu, 16 Apr 2020 15:24:00 +0200 Message-Id: <20200416131256.290378274@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131242.353444678@linuxfoundation.org> References: <20200416131242.353444678@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Duyck commit 8644772637deb121f7ac2df690cbf83fa63d3b70 upstream. This patch replaces the size + 1 value introduced with the recent fix for 1 byte allocs with a constant value. The idea here is to reduce code overhead as the previous logic would have to read size into a register, then increment it, and write it back to whatever field was being used. By using a constant we can avoid those memory reads and arithmetic operations in favor of just encoding the maximum value into the operation itself. Fixes: 2c2ade81741c ("mm: page_alloc: fix ref bias in page_frag_alloc() for 1-byte allocs") Signed-off-by: Alexander Duyck Signed-off-by: David S. Miller Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- mm/page_alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4537,11 +4537,11 @@ refill: /* Even if we own the page, we do not use atomic_set(). * This would break get_page_unless_zero() users. */ - page_ref_add(page, size); + page_ref_add(page, PAGE_FRAG_CACHE_MAX_SIZE); /* reset page count bias and offset to start of new frag */ nc->pfmemalloc = page_is_pfmemalloc(page); - nc->pagecnt_bias = size + 1; + nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; nc->offset = size; } @@ -4557,10 +4557,10 @@ refill: size = nc->size; #endif /* OK, page count is 0, we can safely set it */ - set_page_count(page, size + 1); + set_page_count(page, PAGE_FRAG_CACHE_MAX_SIZE + 1); /* reset page count bias and offset to start of new frag */ - nc->pagecnt_bias = size + 1; + nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; offset = size - fragsz; }