From mboxrd@z Thu Jan 1 00:00:00 1970 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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 65102C2D0DB for ; Fri, 31 Jan 2020 19:15:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 471DB206F0 for ; Fri, 31 Jan 2020 19:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726086AbgAaTPk (ORCPT ); Fri, 31 Jan 2020 14:15:40 -0500 Received: from mga06.intel.com ([134.134.136.31]:5307 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbgAaTPk (ORCPT ); Fri, 31 Jan 2020 14:15:40 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2020 11:15:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,386,1574150400"; d="scan'208";a="377429519" Received: from jekeller-mobl1.amr.corp.intel.com (HELO [134.134.177.86]) ([134.134.177.86]) by orsmga004.jf.intel.com with ESMTP; 31 Jan 2020 11:15:39 -0800 Subject: Re: [PATCH 13/15] devlink: support directly reading from region memory To: Jakub Kicinski Cc: netdev@vger.kernel.org, jiri@resnulli.us, valex@mellanox.com, linyunsheng@huawei.com, lihong.yang@intel.com References: <20200130225913.1671982-1-jacob.e.keller@intel.com> <20200130225913.1671982-14-jacob.e.keller@intel.com> <20200131100744.61ec7632@cakuba.hsd1.ca.comcast.net> From: Jacob Keller Organization: Intel Corporation Message-ID: <4cf21bf4-41f9-7038-da97-114269f67d3f@intel.com> Date: Fri, 31 Jan 2020 11:15:39 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200131100744.61ec7632@cakuba.hsd1.ca.comcast.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 1/31/2020 10:07 AM, Jakub Kicinski wrote: > On Thu, 30 Jan 2020 14:59:08 -0800, Jacob Keller wrote: >> +static int devlink_nl_region_read_direct_fill(struct sk_buff *skb, >> + struct devlink *devlink, >> + struct devlink_region *region, >> + struct nlattr **attrs, >> + u64 start_offset, >> + u64 end_offset, >> + bool dump, >> + u64 *new_offset) >> +{ >> + u64 curr_offset = start_offset; >> + int err = 0; >> + u8 *data; >> + >> + /* Allocate and re-use a single buffer */ >> + data = kzalloc(DEVLINK_REGION_READ_CHUNK_SIZE, GFP_KERNEL); >> + if (!data) >> + return -ENOMEM; >> + >> + *new_offset = start_offset; >> + >> + if (end_offset > region->size || dump) >> + end_offset = region->size; >> + >> + while (curr_offset < end_offset) { >> + u32 data_size; >> + >> + if (end_offset - curr_offset < DEVLINK_REGION_READ_CHUNK_SIZE) >> + data_size = end_offset - curr_offset; >> + else >> + data_size = DEVLINK_REGION_READ_CHUNK_SIZE; > > Also known as min() ? This was more or less adapted from the read_snapshot_fill function. I could probably make more of an effort to share this logic. Thanks, Jake