From: Jacob Keller <jacob.e.keller@intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, jiri@resnulli.us, valex@mellanox.com,
linyunsheng@huawei.com, lihong.yang@intel.com
Subject: Re: [PATCH 04/15] netdevsim: support taking immediate snapshot via devlink
Date: Fri, 31 Jan 2020 10:12:19 -0800 [thread overview]
Message-ID: <eda2109e-edb8-d37c-ca85-80e767cdf89b@intel.com> (raw)
In-Reply-To: <20200131100712.5ba1ce65@cakuba.hsd1.ca.comcast.net>
On 1/31/2020 10:07 AM, Jakub Kicinski wrote:
> On Thu, 30 Jan 2020 14:58:59 -0800, Jacob Keller wrote:
>> Implement the .snapshot region operation for the dummy data region. This
>> enables a region snapshot to be taken upon request via the new
>> DEVLINK_CMD_REGION_SNAPSHOT command.
>>
>> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
>> ---
>> drivers/net/netdevsim/dev.c | 38 +++++++++++++++----
>> .../drivers/net/netdevsim/devlink.sh | 5 +++
>> 2 files changed, 36 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
>> index d521b7bfe007..924cd328037f 100644
>> --- a/drivers/net/netdevsim/dev.c
>> +++ b/drivers/net/netdevsim/dev.c
>> @@ -38,24 +38,47 @@ static struct dentry *nsim_dev_ddir;
>>
>> #define NSIM_DEV_DUMMY_REGION_SIZE (1024 * 32)
>>
>> +static int nsim_dev_take_snapshot(struct devlink *devlink,
>
> nit: break the line after static int, you've done it in other patches
> so I trust you agree it's a superior formatting style :)
>
Sure.
>> + struct netlink_ext_ack *extack,
>> + u8 **data,
>> + devlink_snapshot_data_dest_t **destructor)
>> +{
>> + void *dummy_data;
>> +
>> + dummy_data = kmalloc(NSIM_DEV_DUMMY_REGION_SIZE, GFP_KERNEL);
>> + if (!dummy_data) {
>> + NL_SET_ERR_MSG(extack, "Out of memory");
>
> Unnecessary, there will be an OOM splat, and ENOMEM is basically
> exactly the same as the message.
>
>> + return -ENOMEM;
>> + }
>> +
>> + get_random_bytes(dummy_data, NSIM_DEV_DUMMY_REGION_SIZE);
>> +
>> + *data = dummy_data;
>> + *destructor = kfree;
>
> Is there any driver which uses different destructor for different
> snapshots? Looks like something we could put in ops, maybe?
>
Hmm. Yea I think you're right making this tied to the ops structure
instead of the callback makes sense to me.
>> + return 0;
>> +}
>> +
>> static ssize_t nsim_dev_take_snapshot_write(struct file *file,
>> const char __user *data,
>> size_t count, loff_t *ppos)
>> {
>> struct nsim_dev *nsim_dev = file->private_data;
>> - void *dummy_data;
>> + devlink_snapshot_data_dest_t *destructor;
>> + u8 *dummy_data;
>> int err;
>> u32 id;
>>
>> - dummy_data = kmalloc(NSIM_DEV_DUMMY_REGION_SIZE, GFP_KERNEL);
>> - if (!dummy_data)
>> - return -ENOMEM;
>> -
>> - get_random_bytes(dummy_data, NSIM_DEV_DUMMY_REGION_SIZE);
>> + err = nsim_dev_take_snapshot(priv_to_devlink(nsim_dev), NULL,
>> + &dummy_data, &destructor);
>> + if (err) {
>> + pr_err("Failed to capture region snapshot\n");
>
> Also not a very useful message for netdevsim IMHO give the caller
> clearly requested a snapshot and will get a more informative error
> from errno.
>
Will remove.
>> + return err;
>> + }
>>
>> id = devlink_region_snapshot_id_get(priv_to_devlink(nsim_dev));
>> err = devlink_region_snapshot_create(nsim_dev->dummy_region,
>> - dummy_data, id, kfree);
>> + dummy_data, id, destructor);
>> if (err) {
>> pr_err("Failed to create region snapshot\n");
>> kfree(dummy_data);
next prev parent reply other threads:[~2020-01-31 18:13 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 22:58 [RFC PATCH 00/13] devlink direct region reading Jacob Keller
2020-01-30 22:58 ` [PATCH 01/15] devlink: prepare to support region operations Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-02-03 11:35 ` Jiri Pirko
2020-02-03 16:48 ` Jacob Keller
2020-02-03 17:07 ` Jacob Keller
2020-02-03 17:10 ` Jacob Keller
2020-02-03 17:14 ` Jacob Keller
2020-02-03 17:17 ` Jacob Keller
2020-01-30 22:58 ` [PATCH 02/15] devlink: add functions to take snapshot while locked Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-01-31 18:09 ` Jacob Keller
2020-02-03 11:39 ` Jiri Pirko
2020-02-03 16:45 ` Jacob Keller
2020-01-30 22:58 ` [PATCH 03/15] devlink: add operation to take an immediate snapshot Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-02-03 8:19 ` Yunsheng Lin
2020-02-03 11:50 ` Jiri Pirko
2020-02-03 11:50 ` Jiri Pirko
2020-02-03 16:33 ` Jacob Keller
2020-02-03 19:32 ` Jacob Keller
2020-02-03 21:30 ` Jiri Pirko
2020-02-04 19:20 ` Jacob Keller
2020-01-30 22:58 ` [PATCH 04/15] netdevsim: support taking immediate snapshot via devlink Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-01-31 18:12 ` Jacob Keller [this message]
2020-01-30 22:59 ` [PATCH 05/15] ice: use __le16 types for explicitly Little Endian values Jacob Keller
2020-01-30 22:59 ` [PATCH 06/15] ice: create function to read a section of the NVM and Shadow RAM Jacob Keller
2020-01-30 22:59 ` [PATCH 07/15] ice: implement full NVM read from ETHTOOL_GEEPROM Jacob Keller
2020-01-30 22:59 ` [PATCH 08/15] devlink: add devres managed devlinkm_alloc and devlinkm_free Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-01-31 18:16 ` Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-02-01 0:51 ` Jacob Keller
2020-02-01 17:43 ` Jakub Kicinski
2020-02-03 16:35 ` Jacob Keller
2020-02-03 11:29 ` Jiri Pirko
2020-02-03 16:56 ` Jacob Keller
2020-01-30 22:59 ` [PATCH 09/15] ice: enable initial devlink support Jacob Keller
2020-01-30 22:59 ` [PATCH 10/15] ice: add basic handler for devlink .info_get Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-01-31 18:25 ` Jacob Keller
2020-01-30 22:59 ` [PATCH 11/15] ice: add board identifier info to " Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-01-31 18:26 ` Jacob Keller
2020-01-30 22:59 ` [PATCH 12/15] ice: add a devlink region to dump shadow RAM contents Jacob Keller
2020-01-30 22:59 ` [PATCH 13/15] devlink: support directly reading from region memory Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-01-31 18:27 ` Jacob Keller
2020-01-31 19:15 ` Jacob Keller
2020-02-03 13:44 ` Jiri Pirko
2020-02-03 16:40 ` Jacob Keller
2020-01-30 22:59 ` [PATCH 14/15] ice: support direct read of the shadow ram region Jacob Keller
2020-01-30 22:59 ` [PATCH 15/15] ice: add ice.rst devlink documentation file Jacob Keller
2020-01-31 18:07 ` Jakub Kicinski
2020-01-31 18:28 ` Jacob Keller
2020-01-30 22:59 ` [RFC PATCH 1/3] Update kernel headers Jacob Keller
2020-01-30 22:59 ` [RFC PATCH 2/3] devlink: add support for DEVLINK_CMD_REGION_TAKE_SNAPSHOT Jacob Keller
2020-01-30 22:59 ` [RFC PATCH 3/3] devlink: stop requiring snapshot for regions Jacob Keller
2020-01-30 23:03 ` [RFC PATCH 00/13] devlink direct region reading Jacob Keller
2020-01-31 18:06 ` Jakub Kicinski
2020-01-31 18:09 ` Jacob Keller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eda2109e-edb8-d37c-ca85-80e767cdf89b@intel.com \
--to=jacob.e.keller@intel.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=lihong.yang@intel.com \
--cc=linyunsheng@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=valex@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).