Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1464595pxb; Fri, 20 Aug 2021 06:14:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+xRagysbTLOSBTcs2oETGOO1XhbRuDCPszw2E9mSvF4iBh3L+kQkt5P7taJtmlYLeBfVa X-Received: by 2002:a92:280d:: with SMTP id l13mr13778922ilf.99.1629465268635; Fri, 20 Aug 2021 06:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629465268; cv=none; d=google.com; s=arc-20160816; b=W1sfrVF3ndbISi2hZEG7FgwCXhDOELTdQPbZRLaqPuU/+C9FdWB33RdNQ3T8ReVCHn xGcBRSDN+ewmE1bHQrXBdYKJwtQqc8SwbYXiFsMFh3Wd5daT9UUo8xBGj6vOCXTPXoRk qwm5JlftSb4BvJBOFmtDm3NUPdagKlI3lRZF+aCbkCVgtPiYX3AtOk3FWIKJ94noO7V7 0f69nVkaUc8pdFC/rgI4d1BZmVeqPgKp/PdlUMLuqTYa1NcKwSctBXzzQJHovLT/4u91 89wkBZPqL/BKFpTeZUSCSCVtk1KbK0j69b61bRj41LrXZj8Nb9WPwF3EJBzBZ6u0cs/Q Y81w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=bqh06A4IsUEWpw6rhzLKw/iWZwAPu+rG9dT74f0JO44=; b=po3EtlCK/ivcIOaI4xdp7h/UURWyWyemuMujd3+/JJWpbEppEQNHP7d0v/wFTyYvRx lf4PbD/uhMOqF+SKSDVoRPHA0osDMoMuqSBj3/ohQR8PjdWv4mw6w/jzaDKCzCIVY7zv u4SVK7ryycPlJvpLekf2hZhx1BwIxDYYAPpF+7lfN1WSYk9S5u8HQt55NojOtz7E8Ui0 j++Yu7+OTEyjQ+XcEUdB7pgeaFC7BYsefJBeJnMojOoMaQjeA9snBEdpvXMukiD86niK 6VEvoLELZvcFuDoZ9C+l75HNX6IeKn0/eBQEDrHHl8LzbF6pnWsfK6L2CUKyMn14JplB A9cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L5kJVMfO; 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 k2si6773376ilu.143.2021.08.20.06.14.16; Fri, 20 Aug 2021 06:14:28 -0700 (PDT) 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=L5kJVMfO; 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 S240726AbhHTNMT (ORCPT + 99 others); Fri, 20 Aug 2021 09:12:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38095 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240614AbhHTNMQ (ORCPT ); Fri, 20 Aug 2021 09:12:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629465098; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bqh06A4IsUEWpw6rhzLKw/iWZwAPu+rG9dT74f0JO44=; b=L5kJVMfOpVt3JxEOM8yc4L8dOLIPHTh4cQB6QJ1F2TQgDB3IGnQ5q/KlCYnBd0W41hwZWr j6GAAmIG+Lf7oAwVMSjwYYFdAIQk1VtAFIIbrWa/9vze0pRAZYledT/8TtJU2BrDHcr4l2 BLMp6grb8oo/0qfk0W/SDn0hIUtaKKU= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-593-1WZ0FBx5PcWvM_T2S0nWjw-1; Fri, 20 Aug 2021 09:11:37 -0400 X-MC-Unique: 1WZ0FBx5PcWvM_T2S0nWjw-1 Received: by mail-il1-f198.google.com with SMTP id x3-20020a92de03000000b0022458d4e768so5386305ilm.2 for ; Fri, 20 Aug 2021 06:11:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bqh06A4IsUEWpw6rhzLKw/iWZwAPu+rG9dT74f0JO44=; b=Hi45AaiLwLu6eLCkzAnNh6a9GeahCH92KbTgica/Zadd5L8HvgVKi6/1BfyWvzHkAB bDiFl0+fsB4xQ/rsut5Ga+QN0o/9NsR7t/DAVPCGxvxE6RzsMtf57IsiAdgJP7uXvHXv XUKvh7/VkANO9WqeGL36dfwlrKOkCGRolNtHKRrDsjiIDdGG28PKdNODjueAQWxOmebt wi/q3Vtz/OtgHDx4i17ISXdyTxXEPv1pl10m/WVoY6fsFmZvMUgKaMk7+ZEI015vc6vg jhVtbDEtgow1V4nXrwEwe1LpnKqKe4u2LI7ZziQKsTwfbms4C5pUYbbpcBqwh/bFd/jf vpsw== X-Gm-Message-State: AOAM532Vvu2eoHUCJjOxd2VwsnHpSsLQF9ZaJJpwgwBbzK3jk66tnNe1 99ag4DluSzEjZvwI2Ma/SUMV8Dn6S1B9YRoH3mFuPdKzACRH4A2yhEpluUsXxeblXvyB2OqHFRc CvEhiu/hDj6zFN+yf8b52N1bT X-Received: by 2002:a05:6638:1905:: with SMTP id p5mr17720509jal.25.1629465096939; Fri, 20 Aug 2021 06:11:36 -0700 (PDT) X-Received: by 2002:a05:6638:1905:: with SMTP id p5mr17720468jal.25.1629465096680; Fri, 20 Aug 2021 06:11:36 -0700 (PDT) Received: from [172.16.0.19] (209-212-39-192.brainerd.net. [209.212.39.192]) by smtp.gmail.com with ESMTPSA id k9sm3452624ilo.49.2021.08.20.06.11.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Aug 2021 06:11:36 -0700 (PDT) Subject: Re: [Cluster-devel] [PATCH v6 10/19] gfs2: Introduce flag for glock holder auto-demotion To: Steven Whitehouse , Andreas Gruenbacher , Linus Torvalds , Alexander Viro , Christoph Hellwig , "Darrick J. Wong" Cc: Jan Kara , linux-kernel@vger.kernel.org, Matthew Wilcox , cluster-devel@redhat.com, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com References: <20210819194102.1491495-1-agruenba@redhat.com> <20210819194102.1491495-11-agruenba@redhat.com> <5e8a20a8d45043e88013c6004636eae5dadc9be3.camel@redhat.com> From: Bob Peterson Message-ID: Date: Fri, 20 Aug 2021 08:11:34 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <5e8a20a8d45043e88013c6004636eae5dadc9be3.camel@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/20/21 4:35 AM, Steven Whitehouse wrote: > Hi, > > On Thu, 2021-08-19 at 21:40 +0200, Andreas Gruenbacher wrote: >> From: Bob Peterson >> >> This patch introduces a new HIF_MAY_DEMOTE flag and infrastructure >> that >> will allow glocks to be demoted automatically on locking conflicts. >> When a locking request comes in that isn't compatible with the >> locking >> state of a holder and that holder has the HIF_MAY_DEMOTE flag set, >> the >> holder will be demoted automatically before the incoming locking >> request >> is granted. >> > I'm not sure I understand what is going on here. When there are locking > conflicts we generate call backs and those result in glock demotion. > There is no need for a flag to indicate that I think, since it is the > default behaviour anyway. Or perhaps the explanation is just a bit > confusing... I agree that the whole concept and explanation are confusing. Andreas and I went through several heated arguments about the symantics, comments, patch descriptions, etc. We played around with many different flag name ideas, etc. We did not agree on the best way to describe the whole concept. He didn't like my explanation and I didn't like his. So yes, it is confusing. My preferred terminology was "DOD" or "Dequeue On Demand" which makes the concept more understandable to me. So basically a process can say "I need to hold this glock, but for an unknown and possibly lengthy period of time, but please feel free to dequeue it if it's in your way." And bear in mind that several processes may do the same, simultaneously. You can almost think of this as a performance enhancement. This concept allows a process to hold a glock for much longer periods of time, at a lower priority, for example, when gfs2_file_read_iter needs to hold the glock for very long-running iterative reads. The process requesting a holder with "Demote On Demand" must then determine if its holder has been stolen away (dequeued on demand) after its lengthy operation, and therefore needs to pick up the pieces of where it left off in its process. Meanwhile, another process may need to hold the glock. If its requested mode is compatible, say SH and SH, the lock is simply granted with no further delay. If the mode is incompatible, regardless of whether it's on the local node or a different node in the cluster, these longer-term/lower-priority holders may be dequeued or prempted by another request to hold the glock. Note that although these holders are dequeued-on-demand, they are never "uninitted" as part of the process. Nor must they ever be, since they may be on another process's heap. This differs from the normal glock demote process in which the demote bit is set on ("requesting" the glock be demoted) but still needs to block until the holder does its actual dequeue. >> Processes that allow a glock holder to be taken away indicate this by >> calling gfs2_holder_allow_demote(). When they need the glock again, >> they call gfs2_holder_disallow_demote() and then they check if the >> holder is still queued: if it is, they're still holding the glock; if >> it >> isn't, they need to re-acquire the glock. >> >> This allows processes to hang on to locks that could become part of a >> cyclic locking dependency. The locks will be given up when a (rare) >> conflicting locking request occurs, and don't need to be given up >> prematurely. > This seems backwards to me. We already have the glock layer cache the > locks until they are required by another node. We also have the min > hold time to make sure that we don't bounce locks too much. So what is > the problem that you are trying to solve here I wonder? Again, this is simply allowing premption of lenghy/low-priority holders whereas the normal demote process will only demote when the glock is dequeued after this potentially very-long period of time. The minimum hold time solves a different problem, and Andreas and I talked just yesterday about possibly revisiting how that all works. The problem with minimum hold time is that in many cases the glock state machine does not want to grant new holders if the demote bit is on, so it ends up wasting more time than solving the actual problem. But that's another problem for another day. Regards, Bob Peterson