Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp123786pxk; Tue, 15 Sep 2020 23:10:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRCwBRMBng2jJFhEcvZA9OSGnQ4aynPB4pnnTT7AdnT4AvNUBf84QD7IHuYaYwzun6BQTm X-Received: by 2002:a50:ab13:: with SMTP id s19mr25287480edc.357.1600236631186; Tue, 15 Sep 2020 23:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600236631; cv=none; d=google.com; s=arc-20160816; b=hfwI8J9T+ODByW112391tfbJ39yZqd+ofNmdUY5R9XxTS/bGjpR+t/DCQxAcNjkTR9 FNUO6M9WEHbea4LDp7QKwzh59gmhdHzA4xcosjMvJCsfvvu6jj005Wr+ZQACT7gwG5TI sjiFgFleKctWtvls0d+sNrTYaSq1tsTJ0CieqbWhs12QFNjKPnw+KgJ4PExh+mVDyZoT NmvshFPsPJwG45UPnPX6yFB9xVonQ0TKoXwOwkkwiMgzoTYgDj1gDNeoDE2uW59zU4Q8 tRJJmO5WTuxOagzDG9wKld76gDpKjDwJ6kSkshAkCVkiUADDHJSnm23OT/ZNPoy7j76F /9Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=FILX8ZF1rNUuvb2e2fZU8NgwKYYWJqf30ppLCJV+z6w=; b=zKFhZKwapOafu6atHWeg1bfSKkK4YNwN6X+W4RhC2gMK3gRADdMl4vohdWiHXyO/gj Sh2sqwtCsLpk2UftAmJq6o2fOHh8IP8TtsiAvW+6m7KdphUUb208guDfS/Uh1eW9fPtU j0kChddrXkD8+07L7tqHpPyg4aQR9E59DyfOBIMgmH+0vGwfnCN9ExsnRK4uq50AdlCD RJLNqdenTwEpWf+jWdFV1b0s054DyRD73oIDxHeSGSnLzRgPw/BrR4SyUbLYDDgNwe+K wgAFM+7tcSqLcbJvbfGFwXf7aer57nPAoSYJWLC08PzpYOkXLaAPpVENpNEwrsXywSJK mH5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=d1VzDd3m; 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 m3si10857481eje.124.2020.09.15.23.10.08; Tue, 15 Sep 2020 23:10:31 -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=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=d1VzDd3m; 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 S1726252AbgIPGID (ORCPT + 99 others); Wed, 16 Sep 2020 02:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbgIPGIB (ORCPT ); Wed, 16 Sep 2020 02:08:01 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 711FEC06174A for ; Tue, 15 Sep 2020 23:07:57 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id a9so1623314wmm.2 for ; Tue, 15 Sep 2020 23:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FILX8ZF1rNUuvb2e2fZU8NgwKYYWJqf30ppLCJV+z6w=; b=d1VzDd3mYS7pu2QYeKz1zUzCdKc5ZOp1uul/AVh6cszwZDhJ4wMm02nwguzbaxZzfY obrtxjKsCZjhfYtI7l1LwtVynNLX4bwSx6PQClhoL1eb+e+CFnnuveVEJH7fb6DqcOQg RwEdyfi+ewam84AqUVmS9MXFlmz8B38nkQ1aPScJalZDmRnbPArDO5BVhhlL6ZfYmXuI r18K5A2VtrLnmiIcmJNHKt25PE4HPMk+Y0O8LWT24r7j7Q8BXbYJr24BDFY4IbXOfgWe Vg4Kc3fZVL/ZVtIvde0K5K1MtDD612OPrFdUuapY8puXwbfvcOVUHZQj2d3o1SWis16f unag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FILX8ZF1rNUuvb2e2fZU8NgwKYYWJqf30ppLCJV+z6w=; b=qMp+Mw4jY2Lo7iqwYRC8Ns5mM2kbN0m9uO/Hvw5pBZjbxBE1oOQg2ziKm0pie8rVm8 bu01jvhXrqGGrpSfd8VAXSWpMdSYMl5dG9LAun9Ft5OaAWgEM36ojroDfS+8qfvpnacO hGjOplTofgv6jIhU9QYhO7lTutHQXP6lAA6seF0V58UV8dVhyJINyyNZBX/TyeNmIdC5 F4cYPyG3ZTUJhP2P59Eq3pqrUvtERRI682dJJ07FOTqUsqXrsibDvr9cKDvRfm0xt1by wrYM+66giHwq9MgMTWv1euU/9BbwnDTb4gtctBEtPv8LiQymBHk8//7I8c070PUY7Wkx PG8w== X-Gm-Message-State: AOAM533yNXMeIMFN741BdDNYAe108vhSEEHjPPDjL1HUoFFhxjcD+Ixr o3mf11nRclp3juDLC9bHiLI62g== X-Received: by 2002:a7b:c4c3:: with SMTP id g3mr2835568wmk.128.1600236475870; Tue, 15 Sep 2020 23:07:55 -0700 (PDT) Received: from localhost ([85.163.43.78]) by smtp.gmail.com with ESMTPSA id b84sm3579923wmd.0.2020.09.15.23.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 23:07:55 -0700 (PDT) Date: Wed, 16 Sep 2020 08:07:54 +0200 From: Jiri Pirko To: Moshe Shemesh Cc: Moshe Shemesh , "David S. Miller" , Jakub Kicinski , Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next RFC v4 03/15] devlink: Add reload action stats Message-ID: <20200916060754.GA2278@nanopsycho> References: <1600063682-17313-1-git-send-email-moshe@mellanox.com> <1600063682-17313-4-git-send-email-moshe@mellanox.com> <20200914133939.GG2236@nanopsycho.orion> <20200915133309.GP2236@nanopsycho.orion> <3e5869e2-aad7-0d71-12fb-6d14c76864c9@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3e5869e2-aad7-0d71-12fb-6d14c76864c9@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tue, Sep 15, 2020 at 10:20:39PM CEST, moshe@nvidia.com wrote: > >On 9/15/2020 4:33 PM, Jiri Pirko wrote: >> Tue, Sep 15, 2020 at 02:30:19PM CEST, moshe@nvidia.com wrote: >> > On 9/14/2020 4:39 PM, Jiri Pirko wrote: >> > > Mon, Sep 14, 2020 at 08:07:50AM CEST, moshe@mellanox.com wrote: >> [..] >> >> >> > > > +/** >> > > > + * devlink_reload_implicit_actions_performed - Update devlink on reload actions >> > > > + * performed which are not a direct result of devlink reload call. >> > > > + * >> > > > + * This should be called by a driver after performing reload actions in case it was not >> > > > + * a result of devlink reload call. For example fw_activate was performed as a result >> > > > + * of devlink reload triggered fw_activate on another host. >> > > > + * The motivation for this function is to keep data on reload actions performed on this >> > > > + * function whether it was done due to direct devlink reload call or not. >> > > > + * >> > > > + * @devlink: devlink >> > > > + * @limit_level: reload action limit level >> > > > + * @actions_performed: bitmask of actions performed >> > > > + */ >> > > > +void devlink_reload_implicit_actions_performed(struct devlink *devlink, >> > > > + enum devlink_reload_action_limit_level limit_level, >> > > > + unsigned long actions_performed) >> > > What I'm a bit scarred of that the driver would call this from withing >> > > reload_down()/up() ops. Perheps this could be WARN_ON'ed here (or in >> > > devlink_reload())? >> > > >> > Not sure how I know if it was called from devlink_reload_down()/up() ? Maybe >> > mutex ? So the warn will be actually mutex deadlock ? >> No. Don't abuse mutex for this. >> Just make sure that the counters do not move when you call >> reload_down/up(). >> > >Can make that, but actually I better take devlink->lock anyway in this >function to avoid races, WDYT ? Either you need to protect some data or not. So if you do, do it. > >> > > > +{ >> > > > + if (!devlink_reload_supported(devlink)) >> > > Hmm. I think that the driver does not have to support the reload and can >> > > still be reloaded by another instance and update the stats here. Why >> > > not? >> > > >> > But I show counters only for supported reload actions and levels, otherwise >> > we will have these counters on devlink dev show output for other drivers that >> > don't have support for devlink reload and didn't implement any of these >> > including this function and these drivers may do some actions like >> > fw_activate in another way and don't update the stats and so that will make >> > these stats misleading. They will show history "stats" but they don't update >> > them as they didn't apply anything related to devlink reload. >> The case I tried to point at is the driver instance, that does not >> implement reload ops itself, but still it can be reloaded by someone else - >> the other driver instance outside. >> >> The counters should work no matter if the driver implements reload ops >> or not. Why wouldn't they? The user still likes to know that the devices >> was reloaded. >> > >OK, so you say that every driver should show all counters no matter what >actions it supports and if it supports devlink reload at all, right ? Well, as I wrote in the other email, I think that there should be 2 sets of stats for this. > >> >> > > > + return; >> > > > + devlink_reload_action_stats_update(devlink, limit_level, actions_performed); >> > > > +} >> > > > +EXPORT_SYMBOL_GPL(devlink_reload_implicit_actions_performed); >> > > > + >> > > > static int devlink_reload(struct devlink *devlink, struct net *dest_net, >> > > > enum devlink_reload_action action, >> > > > enum devlink_reload_action_limit_level limit_level, >> > > > - struct netlink_ext_ack *extack, unsigned long *actions_performed) >> > > > + struct netlink_ext_ack *extack, unsigned long *actions_performed_out) >> > > > { >> > > > + unsigned long actions_performed; >> > > > int err; >> > > > >> > > > if (!devlink->reload_enabled) >> > > > @@ -2998,9 +3045,14 @@ static int devlink_reload(struct devlink *devlink, struct net *dest_net, >> > > > if (dest_net && !net_eq(dest_net, devlink_net(devlink))) >> > > > devlink_reload_netns_change(devlink, dest_net); >> > > > >> > > > - err = devlink->ops->reload_up(devlink, action, limit_level, extack, actions_performed); >> > > > + err = devlink->ops->reload_up(devlink, action, limit_level, extack, &actions_performed); >> > > > devlink_reload_failed_set(devlink, !!err); >> > > > - return err; >> > > > + if (err) >> > > > + return err; >> > > > + devlink_reload_action_stats_update(devlink, limit_level, actions_performed); >> > > > + if (actions_performed_out) >> > > Just make the caller to provide valid pointer, as I suggested in the >> > > other patch review. >> > >> > Ack. >> > >> > > > + *actions_performed_out = actions_performed; >> > > > + return 0; >> > > > } >> > > > >> > > > static int >> > > > -- >> > > > 2.17.1 >> > > >