Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp537192ybz; Wed, 22 Apr 2020 03:13:23 -0700 (PDT) X-Google-Smtp-Source: APiQypLAOxG4kSJqRdJczORvffhI4ccR+XHGwfJvkJ6EfHxTnaghO3j/EHepx1uZ3mUYA85Zk0Xk X-Received: by 2002:a05:6402:2076:: with SMTP id bd22mr5804126edb.334.1587550403673; Wed, 22 Apr 2020 03:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587550403; cv=none; d=google.com; s=arc-20160816; b=cL/fGoucgzHaDvFhq3BJnKlop1+uhOpFN2ijUtk/P/YiZ5JsbPxA9wmTBvupjUwOJ8 N8fCnQc7jNmxPEIAIDmRQm9ih8Fd/OpGuSTiOW9f5YdmOyk5H28XQOPWH0RKITPbeqxR z5BpaoB7pnLP0eaeSg1LRTiYj32Dk4fj9fUep5v/SYP5I4wbAJAFGFsoJlkRsxZnOcWA 7ucKbIwEASPUF8+vr+ce1Gng6FQ4gbPUcEVpZNYaggyAvCbQqbofx+PN+4f/on6H+v4Y x4TZbbwrimwQrNURP1QZ1tR6K1NXfM2MEBwJqVynlnvQiL7xSyhjJSRNMcij958UrA/T Jtdw== 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=wqC5x/waL//PIALAQ14x/MQi9QEknt5FINQ2QZAtm3M=; b=Bj8FNCrIqhYOFThqikE0vOtPZpT9jddkKBg1F9W7mW1ggaZ/791jTCe2O58mC+LSiM K9K4hN80tsNdoh1EOD0V7B/1Ncdt3bhsIUj6zn68tAOC7LbvKfgK7WozSpQC34ors/Hv XMzLhsfMazJ1PcZKqpvPGXMAsXk0BqJejBKn4RGlvAAV0qNT1PG6bxlEROgzr31S+6w7 vVK4SZJMTyHgLWAl0h+F47ty7UVXvaTj2GoS5xjwDNdJNbwaTr2heoSXjgOvdwnL+Blw Zrd+1SCcLEhM/xAOo1My9YqvJmAeH1VY6CLjBdU/QsAVnMUI3XGK38VcVPTeU1MAF69L moMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y90UIzhC; 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 mh4si3203133ejb.385.2020.04.22.03.13.00; Wed, 22 Apr 2020 03:13:23 -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=y90UIzhC; 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 S1729121AbgDVKK6 (ORCPT + 99 others); Wed, 22 Apr 2020 06:10:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:41362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729084AbgDVKKv (ORCPT ); Wed, 22 Apr 2020 06:10:51 -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 80D7020575; Wed, 22 Apr 2020 10:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587550250; bh=QxZ8zXJ8KpX3iqu0j8yWWAIOGHgsBEcRzS5kYm1AuSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y90UIzhCBMaIIprAxErbMPeRQHAltZJH/xk4kQC6Ks7YniYkLrfRkplEtulRk/blT nbX5eFxV3R2nWgSFlL1gFaKskwax4cqdRA6kQEPuLTqfZOaYA6chDZviCFP5zgdfMa jZ3TUEbnj/vDGh4l908hcj6hL8i0Jpe6D40/4QtI= 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.14 071/199] mm: Use fixed constant in page_frag_alloc instead of size + 1 Date: Wed, 22 Apr 2020 11:56:37 +0200 Message-Id: <20200422095105.281754538@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200422095057.806111593@linuxfoundation.org> References: <20200422095057.806111593@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 @@ -4325,11 +4325,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; } @@ -4345,10 +4345,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; }