Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21619996rwd; Thu, 29 Jun 2023 19:48:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHlrSAAtA7AcR1VXqon2dRpmYjPDhf77b40gxKfwTXHFGoMFqx79ZazlT7aJkjaXnxqGRn4 X-Received: by 2002:a17:903:2347:b0:1b1:ced7:2c00 with SMTP id c7-20020a170903234700b001b1ced72c00mr1097658plh.19.1688093300427; Thu, 29 Jun 2023 19:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688093300; cv=none; d=google.com; s=arc-20160816; b=XAe3Rw5EwQg2lY+zK/raOXEJBQGC5JpVbGjOODWReLi+QorZgTFkW3U29KQ7tbbXwz e922NFPLvjc0afbsYKXAgL94NqJhfuaQG258BiTyvNFs9zd/iXKDXnteokWqANJrnANR AX7uGh6UMEiQzAAaRTNKGyNs9q7GFYb+VCbkPt7E24n0mpdnWU+HDUOUbzD48aJCh4eT f9B5fHnr8NhIgeKqM5BFzOhaA1e0rHBJcby6uyrnrC9Z8pqqrDwYZ+VlIXIvGmXtc4+X 63HuwYCSZXBXZNw+ss+Hhw1V6Whzi5dF5mg8UdxwNUtp4QFaLT+RwLkzw/fP7jIk8EAm Ewiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=eozCOHF379/U7P4CMNnMXBdKk0ejFm1RduA5sJdcsio=; fh=prpaJtz2kvK6JgUs4447rtm1pDQU9vyI1Km5GBTBT9o=; b=GcWUul6DBgglCK1uF8CSStgw1IHPR0qWvJUp9Yden/6ELGTbbrcIky83TMXTmzS7FK P6Woaflu8JI4tU8o7g1azQD/Q2ryn41li5CZ7h4RyVgOM+LEo1YueyysqjWjTEY7/ww/ y6T2h0kVbS6WBafFrQNyyFzvBiXfGALZJ0QYYBXaIwS944tYD9dNquUXBJSdmMTi6xPM NW9eNJZDk/hsiZJ2xef3tcmutt1tinriNWCHrTFtFjg7M3LG+qJefm0fyemEgRfR0Ggr lJB7YYPBqsmtOq0qWcQbbxdNuFhkew7msdXS4/t0MP4VJRP81KiFy7sSz0gST9cpZQpe xAgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jAaDK47E; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a170902d49100b001a974fc86casi12406020plg.592.2023.06.29.19.47.58; Thu, 29 Jun 2023 19:48:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jAaDK47E; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbjF3Cmo (ORCPT + 99 others); Thu, 29 Jun 2023 22:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjF3Cmn (ORCPT ); Thu, 29 Jun 2023 22:42:43 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 724F4273B for ; Thu, 29 Jun 2023 19:42:42 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1C2721F747; Fri, 30 Jun 2023 02:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1688092961; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eozCOHF379/U7P4CMNnMXBdKk0ejFm1RduA5sJdcsio=; b=jAaDK47Ewl4qdZPwH9HZR1yuczzw1Hbd6bTIi4CsW0vzV7qKAsH0FFmdzXkE8eJ2CI4Nz3 lxLHaNAxPKqzxGLfx9lvMVg9Ofl/uoAJPz0ol6nx2f/OSeVuCZfPW0GSeVNBPQRCVPd6LW 8DI8DgGyK7bz5GtyN6EAhy/cjWMI9EQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1688092961; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eozCOHF379/U7P4CMNnMXBdKk0ejFm1RduA5sJdcsio=; b=mRJpbf4ElSXK4TvGHNV44AP3ZSHf+RkHFtVhxRE/sE5qS4DJlNs4wWwHDKfNaxjka4jF+g pqxwc8Lr4GQdUJBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DAE541391D; Fri, 30 Jun 2023 02:42:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XcqtIh5BnmTIRgAAMHmgww (envelope-from ); Fri, 30 Jun 2023 02:42:38 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever" Cc: linux-nfs@vger.kernel.org, "Chuck Lever" , lorenzo@kernel.org, jlayton@redhat.com, david@fromorbit.com Subject: Re: [PATCH RFC 0/8] RPC service thread scheduler optimizations In-reply-to: <168806401782.1034990.9686296943273298604.stgit@morisot.1015granger.net> References: <168806401782.1034990.9686296943273298604.stgit@morisot.1015granger.net> Date: Fri, 30 Jun 2023 12:42:35 +1000 Message-id: <168809295522.9283.8453285193952262503@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, 30 Jun 2023, Chuck Lever wrote: > Hi - > > Walking a linked list to find an idle thread is not CPU cache- > friendly, and in fact I've noted palpable per-request latency > impacts as the number of nfsd threads on the server increases. > > After discussing some possible improvements with Jeff at LSF/MM, > I've been experimenting with the following series. I've measured an > order of magnitude latency improvement in the thread lookup time, > and have managed to keep the whole thing lockless. > > The only thing I don't like is that allocating the idle bitmaps in > advance means we've got an /a priori/ cap on the number of NFSD > threads that can be created. I'd love to find a way to enable > the pool idle bitmaps to expand dynamically. Suggestions welcome. Hi Chuck, The series looks good. I did notice that patch 6/8 used UINT_MAX and U32_MAX in different places for the same number, though the next patch replaced them both for a new number - the same in both places now. I agree that an a priori cap on number of threads is not ideal. Have you considered using the xarray to only store busy threads? I think its lookup mechanism mostly relies on a bitmap of present entries, but I'm not completely sure. That would require some extra work for svc_stop_threads() which is the only place we are interested in threads that aren't busy. We would need to record a target number of threads, and whenever a thread becomes idle it checks if the number is exceeded. If so it exits decrementing the number of threads, other wise it re-inserts into the xa (if it cannot find a transport to handle). Alternately we could store bitmaps as values in an xarray, much like the ida code does. Thanks, NeilBrown