Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3917128ybz; Mon, 4 May 2020 12:06:24 -0700 (PDT) X-Google-Smtp-Source: APiQypIKeZ3GE4S6corMumQOAsV+RVpmTbQx3ZdlbN65z1F0Ny0a/PkoiqXtlijEVDRq1FXTo5e+ X-Received: by 2002:a05:6402:b4e:: with SMTP id bx14mr15951552edb.1.1588619184221; Mon, 04 May 2020 12:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588619184; cv=none; d=google.com; s=arc-20160816; b=pboQ55uWRhX7M/5agHzB52aMs2CaFy+9G4RIqWlan1Ris0xE0zlV5JQw6SJ2ZIicNW lo2xytk0+5547Td6V1/ab7Laoll3SgOQCaPeuoGYj1aJPRzLbY4IEntW5zsC0tXRbgxo vmjmdacIhObLIftGC7oscmA2ZgDdsZxWvCfXw6R+oA/dWzA9dQW2m6Y5u4BgYGGP8L1k kjihuxwTp5xwYYZXqMbrmkb1YzxDWcGuxmD8PY693hPZg8Mnmj/TYOP+PpqbyKEnRIhs sb2YGafr0Yti/t7AB2Nj9UwPQUyMoFZZzB9B+6/uEtQqZS8Qj5xqwuxeTsWrG8klS2G6 2e0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=m0thDCuKKPB5wtvZ7LxME4MJ/JwJ19M9jIDJMGAVQ/k=; b=x1UVt9OruYKJOpTSlubOfNZo1VNE5lgaIIuOLJcAnu7Rbdfi0bsPMgqFT+dv3I7FZF CjD1VFGqQVK+RdqyUxlaCBdJRyuz+L38L1TWmnEoABiOF6EDCuLhDKdkqgb7+YSkn8Tf siujGmCPYWiixjxwWxLh/CrbYjyW1WlYOCLe2Exdwd+gguxDtS0nhX2J+Ya+kHzsIo6Z gh5cGRVJistl9wAeqJd94m/JbKzv66jeeN5BJGfG2zs+z9aG7EvQWBGosEOxDDvV3HfA txdvb93GzY5yCB5JahJIPrQCRAVMO/HG473pmhE1nsF5P3/hxOtlxgM+vH9HiQOIfvqf wulw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kKX+Yspy; 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 rv13si7456920ejb.115.2020.05.04.12.06.00; Mon, 04 May 2020 12:06:24 -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=@kernel.org header.s=default header.b=kKX+Yspy; 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 S1727030AbgEDTBj (ORCPT + 99 others); Mon, 4 May 2020 15:01:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:49382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbgEDTBj (ORCPT ); Mon, 4 May 2020 15:01:39 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (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 98170206B8; Mon, 4 May 2020 19:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588618898; bh=MZvTpriQkDCS6yqRxLTUdYn57GHFlfAnULhcVOgTV0s=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=kKX+YspymTx4EdBCAjxYqJiqU8K7q7vqO/bLVWsljkl8gg1324SGBiQnFFnAt6yVj Nfbe3D+4NtCAhkzP+5un/QtJ/7hC1Xrq80QVrBavvHpcz2Bd+aghzWi4q1nfwgzx0F zkik0pTJmG3rLaLcP5FxyylUsIDhx5jEYkQsqqtE= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 7989F35226F4; Mon, 4 May 2020 12:01:38 -0700 (PDT) Date: Mon, 4 May 2020 12:01:38 -0700 From: "Paul E. McKenney" To: Joel Fernandes Cc: Uladzislau Rezki , LKML , linux-mm@kvack.org, Andrew Morton , "Theodore Y . Ts'o" , Matthew Wilcox , RCU , Oleksiy Avramchenko Subject: Re: [PATCH 09/24] rcu/tree: cache specified number of objects Message-ID: <20200504190138.GU2869@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200428205903.61704-1-urezki@gmail.com> <20200428205903.61704-10-urezki@gmail.com> <20200501212749.GD7560@paulmck-ThinkPad-P72> <20200504124323.GA17577@pc636> <20200504152437.GK2869@paulmck-ThinkPad-P72> <20200504174822.GA20446@pc636> <20200504180805.GA172409@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200504180805.GA172409@google.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 04, 2020 at 02:08:05PM -0400, Joel Fernandes wrote: > On Mon, May 04, 2020 at 07:48:22PM +0200, Uladzislau Rezki wrote: > > On Mon, May 04, 2020 at 08:24:37AM -0700, Paul E. McKenney wrote: > [..] > > > > > Presumably the list can also be accessed without holding this lock, > > > > > because otherwise we shouldn't need llist... > > > > > > > > > Hm... We increase the number of elements in cache, therefore it is not > > > > lockless. From the other hand i used llist_head to maintain the cache > > > > because it is single linked list, we do not need "*prev" link. Also > > > > we do not need to init the list. > > > > > > > > But i can change it to list_head. Please let me know if i need :) > > > > > > Hmmm... Maybe it is time for a non-atomic singly linked list? In the RCU > > > callback processing, the operations were open-coded, but they have been > > > pushed into include/linux/rcu_segcblist.h and kernel/rcu/rcu_segcblist.*. > > > > > > Maybe some non-atomic/protected/whatever macros in the llist.h file? > > > Or maybe just open-code the singly linked list? (Probably not the > > > best choice, though.) Add comments stating that the atomic properties > > > of the llist functions aren't neded? Something else? > > > > > In order to keep it simple i can replace llist_head by the list_head? > > Just to clarify for me, what is the disadvantage of using llist here? Are there some llist APIs that are not set up for concurrency? I am not seeing any. The overhead isn't that much of a concern, given that these are not on the hotpath, but people reading the code and seeing the cmpxchg operations might be forgiven for believing that there is some concurrency involved somewhere. Or am I confused and there are now single-threaded add/delete operations for llist? > Since we don't care about traversing backwards, isn't it better to use llist > for this usecase? > > I think Vlad is using locking as we're also tracking the size of the llist to > know when to free pages. This tracking could suffer from the lost-update > problem without any locking, 2 lockless llist_add happened simulatenously. > > Also if list_head is used, it will take more space and still use locking. Indeed, it would be best to use a non-concurrent singly linked list. Thanx, Paul > Thoughts? > > thanks, > > - Joel > > > > > > > The comments would be a good start. Just to take pity on people seeing > > > the potential for concurrency and wondering how the concurrent accesses > > > actually happen. ;-) > > > > > Sounds like you are kidding me :) > > > > -- > > Vlad Rezki