From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDEEEC4727E for ; Thu, 1 Oct 2020 23:23:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC73420739 for ; Thu, 1 Oct 2020 23:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601594631; bh=Q2fBrvWt/4ewhM3DRKaD1eRMKPEjHWMU4p0kmjBQJFE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=RrMtrmDdmKWU+hLczbyf1EgnvTxbEt6tIts29QJjaeClAnL90my2oTHrpOEZfGPHL 0qH750b82qRBZC9ecNZyIaOWNQBI9cUEijHk3oNgvp0xLpu1rzvue+8uRNmS5jXF+a liMihFw6kByjPXT1Nxcqamt9VqF1JH4uxCFJXcMQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733119AbgJAXXs (ORCPT ); Thu, 1 Oct 2020 19:23:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:33878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727713AbgJAXXi (ORCPT ); Thu, 1 Oct 2020 19:23:38 -0400 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 501FF20706; Thu, 1 Oct 2020 23:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601594618; bh=Q2fBrvWt/4ewhM3DRKaD1eRMKPEjHWMU4p0kmjBQJFE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=v977ips7DmN88+uWeKBMu/hpAzq2OS8SBOCu+PZLeX3SMY8QGMlAnk7xZEEE5onEt p8hkMv9N3QOD8kDDueIlS8+HKzC6YPPWmN4oxWOMHdHuwzXdJ/ISalguvXoqxat7pD IM8Q3Q5LbyMCoidPL7H56jQzfXRHNCEJWVonuKB4= Date: Thu, 1 Oct 2020 16:23:36 -0700 From: Jakub Kicinski To: saeed@kernel.org Cc: "David S. Miller" , netdev@vger.kernel.org, Eran Ben Elisha , Saeed Mahameed , Moshe Shemesh Subject: Re: [net V2 05/15] net/mlx5: Add retry mechanism to the command entry index allocation Message-ID: <20201001162336.45f552b3@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20201001195247.66636-6-saeed@kernel.org> References: <20201001195247.66636-1-saeed@kernel.org> <20201001195247.66636-6-saeed@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, 1 Oct 2020 12:52:37 -0700 saeed@kernel.org wrote: > +static int cmd_alloc_index_retry(struct mlx5_cmd *cmd) > +{ > + unsigned long alloc_end = jiffies + msecs_to_jiffies(1000); > + int idx; > + > +retry: > + idx = cmd_alloc_index(cmd); > + if (idx < 0 && time_before(jiffies, alloc_end)) { > + /* Index allocation can fail on heavy load of commands. This is a temporary > + * situation as the current command already holds the semaphore, meaning that > + * another command completion is being handled and it is expected to release > + * the entry index soon. > + */ > + cond_resched(); > + goto retry; > + } > + return idx; > +} This looks excessive. At least add some cpu_relax(), or udelay()?