Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1581612rdb; Sun, 19 Nov 2023 01:49:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKEwSwsMc29Ou/440XKvmqMJ2x7gcQtNj9hguuNVN0z3ZDjvY0/dzLOSBfGeOVXaRw/FTJ X-Received: by 2002:a17:903:2292:b0:1cf:595b:eabb with SMTP id b18-20020a170903229200b001cf595beabbmr2005576plh.27.1700387385404; Sun, 19 Nov 2023 01:49:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700387385; cv=none; d=google.com; s=arc-20160816; b=IwOb6tYiVzswU9jqljtRx/VADtC9KRDIQejLgJEAuw31e1hVQ0KTBGzAAetImZcHD3 Nl7TxhX8/FU56XgENfGrv4cp7Ls8PKSOk8+WvIuW1UB/+AvShe1cKdQ7+ibP+eNhDK0F St6qLIIpf4uJ56FbfidP89fdenCGnSY5v9PvnOcCzBXxeEvFU08DfVX2Z9aUFcmJHQJU W1M01P9K690kA+qon+nChbsSRoV3jbumMgR/NxK8yYX3hMtf5EyfTY5eqZzTU9uewM39 6tcsHlkdTI8wLKaGFFmF8z24KXGg8UjILlaIFx3pLqj+3jj8Nqj/NLvvGfBkSBZgEFV+ vBEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Ax0gFVTpxPALNNmYpW6pSbD5cDjfNMiCKpthhKIb0to=; fh=L2JOZ8uTwUhTc+8S+c0qWnLNmHLFItJS+IEvHj2kZPc=; b=BPhP+eIUI828wBf6YJx8wLaejSsUgciZQtn5F8VRFTUb5e7tMur8d6Jx6Qb9EGEmnJ p2MVPnnJBny4kyYhuXmeibAimuiMUtZgfkRcSgdZOtS6CY8VSvvp5uO9Lrq+uxugHI3T 7Y+z1HWCzU751sOFQUCLmMkkA0veM9whQELvrb0eTKQ3WBUDPJr/fkcptDaDC7ry8qKq 31SfhvGBeqmxntOAaV2qOe2V6m80g+SvBlSM6E50kNhGY0G9taaKyxsKG8VqhTr4lH1+ LlL92yLE/fCIQFJl7JbbDR8+mR59vTO35GPG98bUW4eNQAUxZ53PMHWyEc4eRQn9zeUI LEbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T2jv3BUw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id m7-20020a170902db0700b001cf5c997609si399756plx.569.2023.11.19.01.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 01:49:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T2jv3BUw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 1A898808ED88; Sun, 19 Nov 2023 01:49:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbjKSJte (ORCPT + 99 others); Sun, 19 Nov 2023 04:49:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjKSJte (ORCPT ); Sun, 19 Nov 2023 04:49:34 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71933F9 for ; Sun, 19 Nov 2023 01:49:29 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3822C433C7; Sun, 19 Nov 2023 09:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700387369; bh=3a5Gn7rFtAxlkvJ1/i8+/JGUTthS4YkHAdmksXABxx4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T2jv3BUwWQqXgyhazr8XrIoSKX19cOjVLHH2XgcsnFeXxoge5zeLJ4OjAcPUppE44 M679skES7yDoeG+3SubvQ/TLndp8EM/+BdaDX9O3M+mQpA81aSuUVHST56nFRxgq5u BR0eaK+1vjsd/tPoUrDUBRdy6azO/bXfwHq/M85old0xNLwvzdU3S5MrD7kFmP8ydq Jx6rRT44IzWsM85uzumosh8Qou4BWBzbG+uFSrezhnc8+6mjFPMboUSfFdh2mPj+uP 4FhTnRBPQvSqhB+1J7nk472LpELW/yxP2p5zforScxGhfX1wlmo0mdG+1SHS7NMqu9 Kf+a+MM+MGIWg== Date: Sun, 19 Nov 2023 01:49:27 -0800 From: Saeed Mahameed To: Greg Kroah-Hartman Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, Leon Romanovsky , Jason Gunthorpe , Jiri Pirko , Saeed Mahameed Subject: Re: [PATCH 5/5] misc: mlx5ctl: Add umem reg/unreg ioctl Message-ID: References: <20231018081941.475277-1-saeed@kernel.org> <20231018081941.475277-6-saeed@kernel.org> <2023101841-wow-stardust-3c09@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <2023101841-wow-stardust-3c09@gregkh> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 19 Nov 2023 01:49:43 -0800 (PST) On 18 Oct 10:33, Greg Kroah-Hartman wrote: >On Wed, Oct 18, 2023 at 01:19:41AM -0700, Saeed Mahameed wrote: > +#define MLX5CTL_UMEM_MAX_MB 64 >> + >> +static size_t umem_num_pages(u64 addr, size_t len) >> +{ >> + return (size_t)((ALIGN(addr + len, PAGE_SIZE) - >> + ALIGN_DOWN(addr, PAGE_SIZE))) / >> + PAGE_SIZE; >> +} > >We don't have a function or macro for this already? > I looked around and saw similar implementations, but nothing generic, each has different assumptions, for example PAGE_SIZE can be different or base address is assumed to be PAGE aligned, or len has a specific alignment, so each use is a bit different. I managed to reduce this to a one liner in V2. Thanks, Saeed.