Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13938600pxu; Mon, 4 Jan 2021 08:27:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJylgCSKPn9pjEVfweTNeatzCenCmllMax9MgbjtEJFHhD31aarTVIt87bM8etCH9RVLuv7E X-Received: by 2002:a17:906:8587:: with SMTP id v7mr65544829ejx.381.1609777622582; Mon, 04 Jan 2021 08:27:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609777622; cv=none; d=google.com; s=arc-20160816; b=wx72hsLqw4MPatN/CtktSvi3d3/qA5e6Je7ggH7mKLlf1RJWz9gzGEv20UEZhsqjp9 g4invJRujDZgh9E6XfrP47INYn7Fy0dbEMpj6buxUgtkp1jK3GPlnpK9Ssfs0M6vpTZx BgRXG9Dd0VaWxbbXsbX4zN22bz88RZRn+Jhn2278yC7iamC1PKIk+YkTPyariL9GliAB sNjdIOoNhSmJi2Dxs+QoxynsQ8pEBzUFeFDD+9USiJT/uTYVUC1TrCvxPflSPrhOSz+2 nwQzivcdbMe/bIlrnO0DClrglO1+tTWMeRoL6cOu4gU8tryTiA0XpJHlsn6UGfJNfHtH gCDg== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Vnb+cRxFTp9jgAwyYpJAnJI7PWnz4qiNqMQb5deCY4A=; b=d8eV1LN+Woj0t/UQ6jz3FJBqjtm65uYeMukRC+K92Fp63+lEOzChFbzDYcc3fcv0YF YIEANQYoZprZmX4PLCtnUW+/jP7yKgGnNlfHMvgmU6wgPyhhXukAeXaH8kp2fYb4lukF qaTllhVWJmqcUTwFgmF5u8T4I81U0s2QFNohZVfh2/HmAuI4CI8tYjot0IzBeHM2nlCt +XT/DE8CfXQPeKGc4fh9PllHkxHxchfzfWu684QjtoTwIHvzjLgfvxk/91P4vtzDHP34 SdCLKyVSjvlY4VbSMHxbiZw0fJrGhFXunYOE1QLumYnlMofGuAFtSmWAWWdg377bsC0l mUBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hUqSiK6t; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zp23si28348889ejb.261.2021.01.04.08.26.39; Mon, 04 Jan 2021 08:27:02 -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=@redhat.com header.s=mimecast20190719 header.b=hUqSiK6t; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbhADQZ0 (ORCPT + 99 others); Mon, 4 Jan 2021 11:25:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51197 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbhADQZZ (ORCPT ); Mon, 4 Jan 2021 11:25:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609777439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Vnb+cRxFTp9jgAwyYpJAnJI7PWnz4qiNqMQb5deCY4A=; b=hUqSiK6tKUhmY8v/aoJboELQBzmMtWry/YlXpe/gB9/J+Jt1T3cAt4RSq0fKxDGhvVkIqc ZBS5lhWjVSuxxM8oR8y9Mni0GHuotnuEjfdQh7Wp1sNXSnoO2R4UUenLram7sqJh9sj1zx U+HeLi8xvScSadH2KAPf8hgdaK8RYUw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-252-Nd8t6xyPMRG_Mq5LmxPa3A-1; Mon, 04 Jan 2021 11:23:57 -0500 X-MC-Unique: Nd8t6xyPMRG_Mq5LmxPa3A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0FB06107ACE4; Mon, 4 Jan 2021 16:23:56 +0000 (UTC) Received: from bfoster (ovpn-114-23.rdu2.redhat.com [10.10.114.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B4BD71C88; Mon, 4 Jan 2021 16:23:55 +0000 (UTC) Date: Mon, 4 Jan 2021 11:23:53 -0500 From: Brian Foster To: Dave Chinner Cc: Donald Buczek , linux-xfs@vger.kernel.org, Linux Kernel Mailing List , it+linux-xfs@molgen.mpg.de Subject: Re: [PATCH] xfs: Wake CIL push waiters more reliably Message-ID: <20210104162353.GA254939@bfoster> References: <1705b481-16db-391e-48a8-a932d1f137e7@molgen.mpg.de> <20201229235627.33289-1-buczek@molgen.mpg.de> <20201230221611.GC164134@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201230221611.GC164134@dread.disaster.area> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 31, 2020 at 09:16:11AM +1100, Dave Chinner wrote: > On Wed, Dec 30, 2020 at 12:56:27AM +0100, Donald Buczek wrote: > > Threads, which committed items to the CIL, wait in the xc_push_wait > > waitqueue when used_space in the push context goes over a limit. These > > threads need to be woken when the CIL is pushed. > > > > The CIL push worker tries to avoid the overhead of calling wake_all() > > when there are no waiters waiting. It does so by checking the same > > condition which caused the waits to happen. This, however, is > > unreliable, because ctx->space_used can actually decrease when items are > > recommitted. > > When does this happen? > > Do you have tracing showing the operation where the relogged item > has actually gotten smaller? By definition, relogging in the CIL > should only grow the size of the object in the CIL because it must > relog all the existing changes on top of the new changed being made > to the object. Hence the CIL reservation should only ever grow. > > IOWs, returning negative lengths from the formatting code is > unexpected and probably a bug and requires further investigation, > not papering over the occurrence with broadcast wakeups... > I agree that this warrants a bit more explanation and analysis before changing the current code... > > If the value goes below the limit while some threads are > > already waiting but before the push worker gets to it, these threads are > > not woken. > > > > Always wake all CIL push waiters. Test with waitqueue_active() as an > > optimization. This is possible, because we hold the xc_push_lock > > spinlock, which prevents additions to the waitqueue. > > > > Signed-off-by: Donald Buczek > > --- > > fs/xfs/xfs_log_cil.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c > > index b0ef071b3cb5..d620de8e217c 100644 > > --- a/fs/xfs/xfs_log_cil.c > > +++ b/fs/xfs/xfs_log_cil.c > > @@ -670,7 +670,7 @@ xlog_cil_push_work( > > /* > > * Wake up any background push waiters now this context is being pushed. > > */ > > - if (ctx->space_used >= XLOG_CIL_BLOCKING_SPACE_LIMIT(log)) > > + if (waitqueue_active(&cil->xc_push_wait)) > > wake_up_all(&cil->xc_push_wait); > > That just smells wrong to me. It *might* be correct, but this > condition should pair with the sleep condition, as space used by a > CIL context should never actually decrease.... > ... but I'm a little confused by this assertion. The shadow buffer allocation code refers to the possibility of shadow buffers falling out that are smaller than currently allocated buffers. Further, the _insert_format_items() code appears to explicitly optimize for this possibility by reusing the active buffer, subtracting the old size/count values from the diff variables and then reformatting the latest (presumably smaller) item to the lv. Of course this could just be implementation detail. I haven't dug into the details in the remainder of this thread and I don't have specific examples off the top of my head, but perhaps based on the ability of various structures to change formats and the ability of log vectors to shrink in size, shouldn't we expect the possibility of a CIL context to shrink in size as well? Just from poking around the CIL it seems like the surrounding code supports it (xlog_cil_insert_items() checks len > 0 for recalculating split res as well)... Brian > Cheers, > > Dave. > -- > Dave Chinner > david@fromorbit.com >