From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 198E6C47257 for ; Mon, 4 May 2020 19:37:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C928D20705 for ; Mon, 4 May 2020 19:37:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="GObmazAb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C928D20705 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=joelfernandes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 538A98E0079; Mon, 4 May 2020 15:37:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E9488E0058; Mon, 4 May 2020 15:37:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B1308E0079; Mon, 4 May 2020 15:37:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 255248E0058 for ; Mon, 4 May 2020 15:37:47 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DD7D734A3 for ; Mon, 4 May 2020 19:37:46 +0000 (UTC) X-FDA: 76780046532.26.skate00_9aea18d2c958 X-HE-Tag: skate00_9aea18d2c958 X-Filterd-Recvd-Size: 6073 Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 May 2020 19:37:46 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id f3so13649200ioj.1 for ; Mon, 04 May 2020 12:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AdWMO0GZMNFscZNybGWQG3ITswtupKPg+QTxQVbhP58=; b=GObmazAbydGljs6lUpNTgX82Yj9VICjxvJsXCRjiEN/IiUC4gN8U8xjGFwFx9O7ill ZFs+VP0q2tO0znb2WC0f2LJP3cMcp+e1Muf7XNyClzKjOuvajCxdLCIVo5W1RvjY4uOd sLQwXUEOzKPvuukgNeSceNmqwReuSA9lOcGCA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AdWMO0GZMNFscZNybGWQG3ITswtupKPg+QTxQVbhP58=; b=kahOrl1H5znvNJ7nhQtNyfpn6QL8ODMsWceruolYftqUEagfXJKTpHun4jbvjl5CIn 7pt3/jJZJ5xPMLM9wrm5kaYcZ8EPNPtcE0cHe2f6MhHSVFB307DKn3ZP0eJdFz1U6IT/ +Fm38DTEjN5tncWbN7dAPQKIYGIGpMhqFal4zVuFFzbgJ4JSzrNu+6nci1wdQITpJh5X ylYMxHOnGXnHhTrz1O3iOYQA5bQ2JCp8e+AoHJPJUQJMQSrpal6Mhqw2QXHvLMhDrYnz BqqQKaxFSd65WrCgUgDqmXPra41QwYkL8y508SGCzuD7mCUimnO+T9uPtZxYJ+EmjNKn FfTA== X-Gm-Message-State: AGi0PuY2Qof9E8FQJy1VDk7yoJPgcwcx8KztzCD/N2J3x+OmNK14Ep1L viVWcH4PuCykPqbZmvq+qQaRtotxgs6l/sPK/LMD5g== X-Google-Smtp-Source: APiQypLQSD4iaEpIO5FjQ3ZmMTHwJnzzJlOFWYJXTb12bjeP6SAD28w06feWRZUOQRwbhUf9KFyI72uv/kTlXn/A57o= X-Received: by 2002:a6b:bc85:: with SMTP id m127mr3389827iof.89.1588621065701; Mon, 04 May 2020 12:37:45 -0700 (PDT) MIME-Version: 1.0 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> <20200504190138.GU2869@paulmck-ThinkPad-P72> In-Reply-To: <20200504190138.GU2869@paulmck-ThinkPad-P72> From: Joel Fernandes Date: Mon, 4 May 2020 15:37:33 -0400 Message-ID: Subject: Re: [PATCH 09/24] rcu/tree: cache specified number of objects To: "Paul E. McKenney" Cc: Uladzislau Rezki , LKML , linux-mm , Andrew Morton , "Theodore Y . Ts'o" , Matthew Wilcox , RCU , Oleksiy Avramchenko Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Paul, On Mon, May 4, 2020 at 3:01 PM Paul E. McKenney wrote: > > 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. llist deletion racing with another llist deletion will need locking. So strictly speaking, some locking is possible with llist usage? The locklessness as I understand comes when adding and deleting at the same time. For that no lock is needed. But in the current patch, it locks anyway to avoid the lost-update of the size of the list. > 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? I do see some examples of llist usage with locking in the kernel code. One case is: do_init_module() calling llist_add to add to the init_free_list under module_mutex. > > 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. Ok cool :-) Is it safe to say something like the following is ruled out? ;-) :-D #define kfree_rcu_list_add llist_add Thanks, - Joel