From patchwork Thu Apr 27 16:24:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 756083 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wDMjH09jSz9s82 for ; Fri, 28 Apr 2017 02:24:35 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AEFADB62; Thu, 27 Apr 2017 16:24:31 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 77326898 for ; Thu, 27 Apr 2017 16:24:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C4313D4 for ; Thu, 27 Apr 2017 16:24:29 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by relay8-d.mail.gandi.net (Postfix) with ESMTPS id 9895740713 for ; Thu, 27 Apr 2017 18:24:28 +0200 (CEST) Received: from mfilter12-d.gandi.net (mfilter12-d.gandi.net [217.70.178.129]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 80DD141C0A2 for ; Thu, 27 Apr 2017 18:24:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter12-d.gandi.net Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter12-d.gandi.net (mfilter12-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id iFJobVlswAU1 for ; Thu, 27 Apr 2017 18:24:26 +0200 (CEST) X-Originating-IP: 209.85.216.169 Received: from mail-qt0-f169.google.com (mail-qt0-f169.google.com [209.85.216.169]) (Authenticated sender: joe@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id BB3C141C0A7 for ; Thu, 27 Apr 2017 18:24:26 +0200 (CEST) Received: by mail-qt0-f169.google.com with SMTP id g60so30371386qtd.3 for ; Thu, 27 Apr 2017 09:24:26 -0700 (PDT) X-Gm-Message-State: AN3rC/4T9Y4HPJVE81MvFrY2PUL+Wu1jz96Qc6JT7WSGAMs1hfSIl4Bh ngZwhpDG0R7mYvJmYNZHucnYSv03Rw== X-Received: by 10.237.37.195 with SMTP id y3mr5828345qtc.107.1493310265374; Thu, 27 Apr 2017 09:24:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.169.155 with HTTP; Thu, 27 Apr 2017 09:24:04 -0700 (PDT) In-Reply-To: <08F02518-64F5-4F88-9BC8-5099FD6E9F5C@ovn.org> References: <20170427010312.18249-1-joe@ovn.org> <20170427010312.18249-2-joe@ovn.org> <08F02518-64F5-4F88-9BC8-5099FD6E9F5C@ovn.org> From: Joe Stringer Date: Thu, 27 Apr 2017 09:24:04 -0700 X-Gmail-Original-Message-ID: Message-ID: To: Jarno Rajahalme X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: ovs dev , Ansis Atteka Subject: Re: [ovs-dev] [PATCH 2/2] revalidator: Improve logging for transition_ukey(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org On 26 April 2017 at 18:35, Jarno Rajahalme wrote: > >> On Apr 26, 2017, at 6:03 PM, Joe Stringer wrote: >> >> There are a few cases where more introspection into ukey transitions >> would be relevant for logging or assertion. Track the SOURCE_LOCATOR and >> thread id when states are transitioned and use these for logging. >> >> Suggested-by: Jarno Rajahalme >> Signed-off-by: Joe Stringer >> --- >> ofproto/ofproto-dpif-upcall.c | 17 ++++++++++++++++- >> 1 file changed, 16 insertions(+), 1 deletion(-) >> >> diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c >> index ccf15a3c80b3..8aff613161d9 100644 >> --- a/ofproto/ofproto-dpif-upcall.c >> +++ b/ofproto/ofproto-dpif-upcall.c >> @@ -281,6 +281,10 @@ struct udpif_key { >> uint64_t reval_seq OVS_GUARDED; /* Tracks udpif->reval_seq. */ >> enum ukey_state state OVS_GUARDED; /* Tracks ukey lifetime. */ >> >> + /* 'state' debug information. */ >> + unsigned int state_thread OVS_GUARDED; /* Thread that transitions. */ >> + const char *state_where OVS_GUARDED; /* transition_ukey() locator. */ >> + >> /* Datapath flow actions as nlattrs. Protected by RCU. Read with >> * ukey_get_actions(), and write with ukey_set_actions(). */ >> OVSRCU_TYPE(struct ofpbuf *) actions; >> @@ -1484,6 +1488,8 @@ ukey_create__(const struct nlattr *key, size_t key_len, >> ukey->dump_seq = dump_seq; >> ukey->reval_seq = reval_seq; >> ukey->state = UKEY_CREATED; >> + ukey->state_thread = ovsthread_id_self(); >> + ukey->state_where = OVS_SOURCE_LOCATOR; >> ukey->created = time_msec(); >> memset(&ukey->stats, 0, sizeof ukey->stats); >> ukey->stats.used = used; >> @@ -1674,7 +1680,11 @@ static void >> transition_ukey(struct udpif_key *ukey, enum ukey_state dst) >> OVS_REQUIRES(ukey->mutex) >> { >> - ovs_assert(dst >= ukey->state); >> + if (dst >= ukey->state) { >> + VLOG_ABORT("Invalid ukey transition %d->%d (last transitioned from " >> + "thread %u at %s)", ukey->state, dst, ukey->state_thread, >> + ukey->state_where); >> + } >> if (ukey->state == dst && dst == UKEY_OPERATIONAL) { >> return; >> } >> @@ -1709,6 +1719,8 @@ transition_ukey(struct udpif_key *ukey, enum ukey_state dst) >> ds_cstr(&ds), ukey->state, dst); >> ds_destroy(&ds); >> } >> + ukey->state_thread = ovsthread_id_self(); >> + ukey->state_where = OVS_SOURCE_LOCATOR; > > You’ll want to evaluate OVS_SOURCE_LOCATOR at the caller of the transition_ukey() instead. Top do that you’ll need to add a “const char *where” argument, and then make a macro that uses OVS_SOURCE_LOCATOR as that additional argument, and make the callers use the new macro instead of calling the function directly. > > As is it will always report the same line (right here). Thanks for the reviews. I plan to roll in the following incremental before applying to master and branch-2.7: const unsigned pmd_id); @@ -1677,7 +1680,8 @@ ukey_install__(struct udpif *udpif, struct udpif_key *new_ukey) } static void -transition_ukey(struct udpif_key *ukey, enum ukey_state dst) +transition_ukey_at(struct udpif_key *ukey, enum ukey_state dst, + const char *where) OVS_REQUIRES(ukey->mutex) { if (dst >= ukey->state) { @@ -1720,7 +1724,7 @@ transition_ukey(struct udpif_key *ukey, enum ukey_state dst) ds_destroy(&ds); } ukey->state_thread = ovsthread_id_self(); - ukey->state_where = OVS_SOURCE_LOCATOR; + ukey->state_where = where; } static bool diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 8aff613161d9..25aa8f2a92bc 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -354,8 +354,11 @@ static void ukey_get_actions(struct udpif_key *, const struct nlattr **actions, static bool ukey_install__(struct udpif *, struct udpif_key *ukey) OVS_TRY_LOCK(true, ukey->mutex); static bool ukey_install(struct udpif *udpif, struct udpif_key *ukey); -static void transition_ukey(struct udpif_key *ukey, enum ukey_state dst) +static void transition_ukey_at(struct udpif_key *ukey, enum ukey_state dst, + const char *where) OVS_REQUIRES(ukey->mutex); +#define transition_ukey(UKEY, DST) \ + transition_ukey_at(UKEY, DST, OVS_SOURCE_LOCATOR) static struct udpif_key *ukey_lookup(struct udpif *udpif, const ovs_u128 *ufid,