From patchwork Thu Jun 4 21:42:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 217988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC8ECC433E0 for ; Thu, 4 Jun 2020 21:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7E142067B for ; Thu, 4 Jun 2020 21:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728132AbgFDVnB (ORCPT ); Thu, 4 Jun 2020 17:43:01 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:33712 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgFDVnB (ORCPT ); Thu, 4 Jun 2020 17:43:01 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 1E05B1C0BD2; Thu, 4 Jun 2020 23:43:00 +0200 (CEST) Date: Thu, 4 Jun 2020 23:42:59 +0200 From: Pavel Machek To: bjorn.topel@intel.com, magnus.karlsson@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, netdev@vger.kernel.org, trivial@kernel.org Subject: [PATCH] net/xdp: use shift instead of 64 bit division Message-ID: <20200604214259.GA10835@amd> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 64bit division is kind of expensive, and shift should do the job here. Signed-off-by: Pavel Machek (CIP) --- Now with patch. Sorry about that. diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c index 3889bd9aec46..d6c91a43a1ee 100644 --- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c @@ -372,7 +372,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) if ((addr + size) < addr) return -EINVAL; - npgs = div_u64(size, PAGE_SIZE); + npgs = size >> PAGE_SHIFT; if (npgs > U32_MAX) return -EINVAL;