Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1093444pxb; Fri, 21 Jan 2022 09:42:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7ZzDVxB1I1CZxfeYFsWXhgiRmpPMlQrweK2M2O4ZfikdKZQKI/sBPNgeFpstMJhVoDFVx X-Received: by 2002:a17:90a:a105:: with SMTP id s5mr1766593pjp.170.1642786952827; Fri, 21 Jan 2022 09:42:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642786952; cv=none; d=google.com; s=arc-20160816; b=VpsTOMJM507VbHnD/x/x72zJlceHDSweAV/EOdNxGGvw6LbBFZncrApJkrIAhM6fNk a80VceMuYGNc6Lsugqa1Mt0BJztFEk6fNO7OKgBGSK1lBGbsjSaAGHZqy0weujhk1zFC bKX0EuOHy/BUnAySPUw2poljvSP5+26NoGYlaLd69sRuWhkjVTtgNiZWT1+y7NA7Ax6M GTCID3ZKWVX7vawojNLz5omZ2kEkl9x2Xmx2MJKO8QiMAyNzIt6BfuT+wIn2TsI5awZ0 8Zw6m3bbfIVkHbGwKnXgKLBYIfwhO7hjxvnSgMPyPi3d7MMQO816WvuC2wINCjWhfLQt JGZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TuumKKgylRlkOOgJri15uoluPFLL9igotQVC5fjOgEs=; b=AQItHmMdAhJNWRO4lN/LIqwt4gn6NyrMjswcbNLf22OvVug827GvdebhiYaJcxjfuH yF+5Cv6AYbx0LutVi4BXXiOuDnXB3JfXcRmvrwkRzx4rz/FICAtLXkiTK65qf4frSCLt /RkrqDl8tXptnQ1/DuwWTflf19nflXoZt4QHu5U5jiIBntmuBxXWftQzkYYgR1j2KRIk PGnWoX8Yq/z4iX5O4WfjZn8MdS+fl8ESG08dwOv3PT59CMjuHse55+Xw1W6zefqL40i2 OQWp7JEk6TxFIu5Aqci9FYtjgrR8yfGf/9srwyV73kaSQGwjJ6oZz1qZMR+88EdejEce swUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MTdMtvye; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si6542574pgj.367.2022.01.21.09.42.13; Fri, 21 Jan 2022 09:42:32 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=MTdMtvye; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351870AbiASG7M (ORCPT + 99 others); Wed, 19 Jan 2022 01:59:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242328AbiASG7H (ORCPT ); Wed, 19 Jan 2022 01:59:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9DC3C061574; Tue, 18 Jan 2022 22:59:06 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 796E7612C4; Wed, 19 Jan 2022 06:59:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A6B2C004E1; Wed, 19 Jan 2022 06:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642575545; bh=Pt6R+AEyWFXdl8U2QBDrYxNGlP3nwbUyAONzX9MOrdo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MTdMtvyeQgpsClX00DEelSBLn913bNw7uxDN+W+kBWvauruTkTdCsaourTerq8u6c wxsw+r9+VF+3kaODHvpTkjMIOSd+fFwlNx43Dwnqicr/X0cf0fSCdFPtmgVsOPMDKp qZshUoXeHdr5AWUCOa2w9KraBYymGFktTBA5/p4P5WioLMRHOgcrheY0G+fqzvkodE NfEaly2aSOZcmgS32qwnKA+jsjGiEa6lBRrs1jVZUN0ZCFP5XY6EV9AXeMFpWtaM1A 8BH9UMpGp3tMRIUEUdHN5UEDb/RrYWmav3w1zCDQkTBB1f5eqFzRar0Lf/mfHYHEJt Y8NS8Ldl2m+YA== Date: Wed, 19 Jan 2022 08:59:00 +0200 From: Leon Romanovsky To: Santosh Shilimkar Cc: Jason Gunthorpe , Praveen Kannoju , "David S . Miller" , "kuba@kernel.org" , "netdev@vger.kernel.org" , "linux-rdma@vger.kernel.org" , "rds-devel@oss.oracle.com" , "linux-kernel@vger.kernel.org" , Rama Nichanamatlu , Rajesh Sivaramasubramaniom Subject: Re: [PATCH RFC] rds: ib: Reduce the contention caused by the asynchronous workers to flush the mr pool Message-ID: References: <1642517238-9912-1-git-send-email-praveen.kannoju@oracle.com> <53D98F26-FC52-4F3E-9700-ED0312756785@oracle.com> <20220118191754.GG8034@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 18, 2022 at 07:42:54PM +0000, Santosh Shilimkar wrote: > On Jan 18, 2022, at 11:17 AM, Jason Gunthorpe wrote: > > > > On Tue, Jan 18, 2022 at 04:48:43PM +0000, Santosh Shilimkar wrote: > >> > >>> On Jan 18, 2022, at 6:47 AM, Praveen Kannoju wrote: > >>> > >>> This patch aims to reduce the number of asynchronous workers being spawned > >>> to execute the function "rds_ib_flush_mr_pool" during the high I/O > >>> situations. Synchronous call path's to this function "rds_ib_flush_mr_pool" > >>> will be executed without being disturbed. By reducing the number of > >>> processes contending to flush the mr pool, the total number of D state > >>> processes waiting to acquire the mutex lock will be greatly reduced, which > >>> otherwise were causing DB instance crash as the corresponding processes > >>> were not progressing while waiting to acquire the mutex lock. > >>> > >>> Signed-off-by: Praveen Kumar Kannoju > >>> — > >>> > >> […] > >> > >>> diff --git a/net/rds/ib_rdma.c b/net/rds/ib_rdma.c > >>> index 8f070ee..6b640b5 100644 > >>> +++ b/net/rds/ib_rdma.c > >>> @@ -393,6 +393,8 @@ int rds_ib_flush_mr_pool(struct rds_ib_mr_pool *pool, > >>> */ > >>> dirty_to_clean = llist_append_to_list(&pool->drop_list, &unmap_list); > >>> dirty_to_clean += llist_append_to_list(&pool->free_list, &unmap_list); > >>> + WRITE_ONCE(pool->flush_ongoing, true); > >>> + smp_wmb(); > >>> if (free_all) { > >>> unsigned long flags; > >>> > >>> @@ -430,6 +432,8 @@ int rds_ib_flush_mr_pool(struct rds_ib_mr_pool *pool, > >>> atomic_sub(nfreed, &pool->item_count); > >>> > >>> out: > >>> + WRITE_ONCE(pool->flush_ongoing, false); > >>> + smp_wmb(); > >>> mutex_unlock(&pool->flush_lock); > >>> if (waitqueue_active(&pool->flush_wait)) > >>> wake_up(&pool->flush_wait); > >>> @@ -507,8 +511,17 @@ void rds_ib_free_mr(void *trans_private, int invalidate) > >>> > >>> /* If we've pinned too many pages, request a flush */ > >>> if (atomic_read(&pool->free_pinned) >= pool->max_free_pinned || > >>> - atomic_read(&pool->dirty_count) >= pool->max_items / 5) > >>> - queue_delayed_work(rds_ib_mr_wq, &pool->flush_worker, 10); > >>> + atomic_read(&pool->dirty_count) >= pool->max_items / 5) { > >>> + smp_rmb(); > >> You won’t need these explicit barriers since above atomic and write once already > >> issue them. > > > > No, they don't. Use smp_store_release() and smp_load_acquire if you > > want to do something like this, but I still can't quite figure out if > > this usage of unlocked memory accesses makes any sense at all. > > > Indeed, I see that now, thanks. Yeah, these multi variable checks can indeed > be racy but they are under lock at least for this code path. But there are few > hot path places where single variable states are evaluated atomically instead of > heavy lock. At least pool->dirty_count is not locked in rds_ib_free_mr() at all. Thanks > > Regards, > Santosh >