Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp557312pxb; Thu, 20 Jan 2022 20:18:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuVdmqgKyUFB+GU4oXxgbNpwfMWU6cngdkign/Oze7u1mYDMkBygeUDpBj6PFLnHstqgl5 X-Received: by 2002:a17:902:c404:b0:14a:1594:2e69 with SMTP id k4-20020a170902c40400b0014a15942e69mr2437872plk.167.1642738686911; Thu, 20 Jan 2022 20:18:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642738686; cv=none; d=google.com; s=arc-20160816; b=uQW0f3mbHohnynCif7LRmNBeZW9PfaE1i5Uaj4DwHAK4YbyQW7keg0VdD3dgLxGNaT gtAS/Ht0NB2rlyz1zpBRhscbd7yvMMsNU2Kil1nwzrwaDaM9MBLgA67JytAJsOC1atMa dsYVbgQBHlwSbdNQ3qX4eU60+k9Fk2afKxwVjHdC39oCmtMh0M0JUw0ec5sIdZ9/xUIA IM+NiGeeg/x5EJCcJWe7T4MCEMJXwI5f+8QHpMZpBjTHi4+P46Zy5eQJDabUpnogoV8o aib117cSHBJwd0BIZkMsP5ZE9czmw03Vw6uCzOXAsvsicCWDlclhHaeJ8cwJ8rpr8TZ9 kBHQ== 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=XLdOdrMhGx+uWKyGybpz2Ct3QQEBAUUynbEFITHgPLY=; b=zmbViJNsQa8t4xUHqo+e7fAcpjIJD/2DWpr8/WQVnkwLbi/q88LVeLItfpBESQl2Xa e1dTkF6T47b5xJU064G9EeuWVfgSBWANnxtQ4Oz2pa7VvW4PE/yASqJ0n/vlUG/ys/EI svpzMVwSvrzKXnPMEHFpngSm4tyBhx2lKI7OA+ZGUXHSVmDmXzol+Z1Uyz1Vhj8Sem2a 12Y5OUoyiAOkfk0WrDeKhUPC9kQNA2ZGqL2encFnj1v4krQ/wh6xMTwGxrj9DoGjOZrn Cyz13RAf5gnONJl9VOzdwNC0XiLg0/ml3LwBvyDvooEKeO2e0ytao4UDwCUzIvS9E1/J qiew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=eqv3DAHB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s31si5828919pfg.236.2022.01.20.20.17.54; Thu, 20 Jan 2022 20:18:06 -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=@ziepe.ca header.s=google header.b=eqv3DAHB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348636AbiARTSC (ORCPT + 99 others); Tue, 18 Jan 2022 14:18:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348572AbiARTR4 (ORCPT ); Tue, 18 Jan 2022 14:17:56 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADED7C06173E for ; Tue, 18 Jan 2022 11:17:56 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id jr5so259528qvb.11 for ; Tue, 18 Jan 2022 11:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=XLdOdrMhGx+uWKyGybpz2Ct3QQEBAUUynbEFITHgPLY=; b=eqv3DAHBk+Hy73moYerjN9BAfZaKoSsxduKm5/A3uOEeVXd4K+fBAqeukoaBam4xMe jpvd9jYkFSO8zxC5sGg1BTH6C8kch//t5eYUcvjYP6cnh3O61jqBS9IzQgGTbEri6aRv 2HiAnUw4WVgh70N/97NoOPdhmIub7SiY116iHt+tdQdFRLshMx7+B/qYOlEo2viw+kzM FQFlk1E4Y5De/equbwCndPWUs8m45zdSWr6r7Wjd0EodoExdxRRC+zs/QG7asATRRpxD BdWTEhi3UTRJycTiLMY/+iO943kr8qPscgMKYHTPuD0sy9jEQogCET9iyqSScPFg+bG4 SKPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=XLdOdrMhGx+uWKyGybpz2Ct3QQEBAUUynbEFITHgPLY=; b=4eLWDxv7GPll/vRhx6xHgEjv2KTGy4E08nTFpy7YtsGSFgs32R+ZcBQeVMXDg/t2gC xDrUvJMCJIrcW1/uxfnG83Xn8cOi49FOBOl0SPd4zyYif5hjv7fEm49xVnn0BESi14zB Uw96RF3WP1p/eVV7P8LAjEWFrH+BpvZYxJ+L3gnx8PxXLuh/ZKkaVTwmVTj8p4+pFUBs b6Bk9qCUpqUBbKuhsEDfn9JXk/h3s7Rf9oQMULHrRzIfkAeScu0GP/gghmEOnA2S0rZr HHoieLlIvr11F3Kg7lpe/9yEBQLEwXT6WmKSUQ/Fuw3kqRLqRrnNiLAZbcl2Xp+Pewx3 dfbQ== X-Gm-Message-State: AOAM530A+hITpr6h7fkljdtZZF5NvT7dR/xW9X621CHbR3yYhBVfSvh1 y8sqjjHx7oP867dNKcZNxwLm7g== X-Received: by 2002:ad4:4ea2:: with SMTP id ed2mr24831618qvb.128.1642533475885; Tue, 18 Jan 2022 11:17:55 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id s10sm11405313qko.104.2022.01.18.11.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 11:17:55 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1n9tzO-0012Oy-6w; Tue, 18 Jan 2022 15:17:54 -0400 Date: Tue, 18 Jan 2022 15:17:54 -0400 From: Jason Gunthorpe To: Santosh Shilimkar Cc: 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: <20220118191754.GG8034@ziepe.ca> References: <1642517238-9912-1-git-send-email-praveen.kannoju@oracle.com> <53D98F26-FC52-4F3E-9700-ED0312756785@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <53D98F26-FC52-4F3E-9700-ED0312756785@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Jason