Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5328140rdb; Wed, 13 Dec 2023 05:55:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUeSWJhsDaao/0k9/4mYW9dJvxmE8Xp4bikGSS2eGjGBPw0Td09YHf4sRTbmsF5Lrbl65u X-Received: by 2002:a05:6a00:8b01:b0:6ce:38fd:5124 with SMTP id if1-20020a056a008b0100b006ce38fd5124mr2977237pfb.60.1702475718576; Wed, 13 Dec 2023 05:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702475718; cv=none; d=google.com; s=arc-20160816; b=iKgH8G3WZXQf8mFp74sm0CoRqlQgax1sTQdalgYCf8ZhRZWREgl7LieFcI59YZ6va2 p5nF5RJGgPrinKs4/F6yVm7fcHRsDA+0J1N2yBtpqpsLgDEWIpnct0/BzILyg+S8enRU zjOmiHDSU8jCOmjQavH4Hr6Cx7z3ZZQ1HxfjIgazq8VqYFky7bBk+tv3YSVONqEsJ5Nw ie7YTjJk+LD/X0UwOxU5Wk/e3zvwKgdCII380p9JOm7umS2o6ExISWSoog0m4NX1g30S BFED1SxfotQxLXJQt3TFgBHTfjGF0tvqnDCPSWqr5G3D0iEZsnxP3KSpdu843uni9HcJ 9k1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9uxlhhzYOJGE/EnjwXuTD2EVqz5vY7VT/PkRDYqehTo=; fh=9hT4l0EMR1D2zdgUoRXiqFwsybSJyrmM/FC/blQlPsI=; b=xpAzG6gj8SrqTml8KLpcxuc3/eYQ93CQ7OwWaJlfugl3vCpg14vt5MyAZbRQw2u/zo ThMyWT6sJ7ugbCv5lZ2h8aGNagNopIAgqsK9/qHnYSvaDtlVC5bYqXPrSTKE6xPjHJVr odlupxH6eVmEUcQ0JigbIEjwY1yc/ugREZCHIqYNxKI/k5rcXd7/lE/RKXSxMInVyPkC 7yCSfMQSGEnIgM3kgv2uqwhqCZj73n9K8Xnh/mmQoAllUkvymMuzj06UFE/M6EOhBp/r ZY80/sM2/ZHWvJWsCuOHKiM7xYMomt0+3rqT357KJr/o0ZglgXFGNPuRtrfM9UueAERn +Tww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="X/zPZk+Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s36-20020a056a0017a400b006cea00de0f4si9689979pfg.105.2023.12.13.05.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:55:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="X/zPZk+Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BD4A58056994; Wed, 13 Dec 2023 05:55:05 -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 S1379342AbjLMNwI (ORCPT + 99 others); Wed, 13 Dec 2023 08:52:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379338AbjLMNvD (ORCPT ); Wed, 13 Dec 2023 08:51:03 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D626412D for ; Wed, 13 Dec 2023 05:50:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702475453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9uxlhhzYOJGE/EnjwXuTD2EVqz5vY7VT/PkRDYqehTo=; b=X/zPZk+Yb9HwOsmmfAVdTE7026F6eSHai62SiEHrlfEkEbTLKJbAEshQB3jNW7SVCZPSam muYvvctR+QXjG5FA5CTXU/H9sYfZqXTiASAhhCqTMcdkNeIpoVnXKgKFk0ji5Gk22k0H0L Hps6D6gtcS9FUhSb7SvjBjN+sBEF96s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-uz8qfnuzN8GJS4LAl_yvKg-1; Wed, 13 Dec 2023 08:50:49 -0500 X-MC-Unique: uz8qfnuzN8GJS4LAl_yvKg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9371C185A785; Wed, 13 Dec 2023 13:50:49 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id C77C740C6EBA; Wed, 13 Dec 2023 13:50:48 +0000 (UTC) From: David Howells To: Marc Dionne Cc: David Howells , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 27/40] afs: Dispatch vlserver probes in priority order Date: Wed, 13 Dec 2023 13:49:49 +0000 Message-ID: <20231213135003.367397-28-dhowells@redhat.com> In-Reply-To: <20231213135003.367397-1-dhowells@redhat.com> References: <20231213135003.367397-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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]); Wed, 13 Dec 2023 05:55:05 -0800 (PST) When probing all the addresses for a volume location server, dispatch them in order of descending priority to try and get back highest priority one first. Also add a tracepoint to show the transmission and completion of the probes. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/internal.h | 1 + fs/afs/vl_list.c | 2 ++ fs/afs/vl_probe.c | 20 ++++++++++++++++++-- include/trace/events/afs.h | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 9a1e151e77e7..88db04220773 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -447,6 +447,7 @@ struct afs_vlserver { rwlock_t lock; /* Lock on addresses */ refcount_t ref; unsigned int rtt; /* Server's current RTT in uS */ + unsigned int debug_id; /* Probe state */ wait_queue_head_t probe_wq; diff --git a/fs/afs/vl_list.c b/fs/afs/vl_list.c index 5c4cd71caccf..9b1c20daac53 100644 --- a/fs/afs/vl_list.c +++ b/fs/afs/vl_list.c @@ -13,6 +13,7 @@ struct afs_vlserver *afs_alloc_vlserver(const char *name, size_t name_len, unsigned short port) { struct afs_vlserver *vlserver; + static atomic_t debug_ids; vlserver = kzalloc(struct_size(vlserver, name, name_len + 1), GFP_KERNEL); @@ -21,6 +22,7 @@ struct afs_vlserver *afs_alloc_vlserver(const char *name, size_t name_len, rwlock_init(&vlserver->lock); init_waitqueue_head(&vlserver->probe_wq); spin_lock_init(&vlserver->probe_lock); + vlserver->debug_id = atomic_inc_return(&debug_ids); vlserver->rtt = UINT_MAX; vlserver->name_len = name_len; vlserver->service_id = VL_SERVICE; diff --git a/fs/afs/vl_probe.c b/fs/afs/vl_probe.c index f868ae5d40e5..b128dc3d8af7 100644 --- a/fs/afs/vl_probe.c +++ b/fs/afs/vl_probe.c @@ -131,6 +131,7 @@ void afs_vlserver_probe_result(struct afs_call *call) out: spin_unlock(&server->probe_lock); + trace_afs_vl_probe(server, false, alist, index, call->error, call->abort_code, rtt_us); _debug("probe [%u][%u] %pISpc rtt=%d ret=%d", server_index, index, rxrpc_kernel_remote_addr(addr->peer), rtt_us, ret); @@ -150,8 +151,10 @@ static bool afs_do_probe_vlserver(struct afs_net *net, { struct afs_addr_list *alist; struct afs_call *call; - unsigned int index; + unsigned long unprobed; + unsigned int index, i; bool in_progress = false; + int best_prio; _enter("%s", server->name); @@ -165,7 +168,20 @@ static bool afs_do_probe_vlserver(struct afs_net *net, memset(&server->probe, 0, sizeof(server->probe)); server->probe.rtt = UINT_MAX; - for (index = 0; index < alist->nr_addrs; index++) { + unprobed = (1UL << alist->nr_addrs) - 1; + while (unprobed) { + best_prio = -1; + index = 0; + for (i = 0; i < alist->nr_addrs; i++) { + if (test_bit(i, &unprobed) && + alist->addrs[i].prio > best_prio) { + index = i; + best_prio = alist->addrs[i].prio; + } + } + __clear_bit(index, &unprobed); + + trace_afs_vl_probe(server, true, alist, index, 0, 0, 0); call = afs_vl_get_capabilities(net, alist, index, key, server, server_index); if (!IS_ERR(call)) { diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h index 81eb87fbcfa7..f1815b3dafb0 100644 --- a/include/trace/events/afs.h +++ b/include/trace/events/afs.h @@ -1420,6 +1420,40 @@ TRACE_EVENT(afs_fs_probe, &__entry->srx.transport) ); +TRACE_EVENT(afs_vl_probe, + TP_PROTO(struct afs_vlserver *server, bool tx, struct afs_addr_list *alist, + unsigned int addr_index, int error, s32 abort_code, unsigned int rtt_us), + + TP_ARGS(server, tx, alist, addr_index, error, abort_code, rtt_us), + + TP_STRUCT__entry( + __field(unsigned int, server) + __field(bool, tx) + __field(unsigned short, flags) + __field(u16, addr_index) + __field(short, error) + __field(s32, abort_code) + __field(unsigned int, rtt_us) + __field_struct(struct sockaddr_rxrpc, srx) + ), + + TP_fast_assign( + __entry->server = server->debug_id; + __entry->tx = tx; + __entry->addr_index = addr_index; + __entry->error = error; + __entry->abort_code = abort_code; + __entry->rtt_us = rtt_us; + memcpy(&__entry->srx, rxrpc_kernel_remote_srx(alist->addrs[addr_index].peer), + sizeof(__entry->srx)); + ), + + TP_printk("vl=%08x %s ax=%u e=%d ac=%d rtt=%d %pISpc", + __entry->server, __entry->tx ? "tx" : "rx", __entry->addr_index, + __entry->error, __entry->abort_code, __entry->rtt_us, + &__entry->srx.transport) + ); + #endif /* _TRACE_AFS_H */ /* This part must be outside protection */