Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5975176imm; Sat, 19 May 2018 14:04:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoFra28YKZ173Gpnb2ZLr59oNX42GqwVgdPz4trGm/1ojklEANMSrG68r/WyGh2y4t1UsTK X-Received: by 2002:a17:902:aa4b:: with SMTP id c11-v6mr14736196plr.17.1526763892153; Sat, 19 May 2018 14:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526763892; cv=none; d=google.com; s=arc-20160816; b=eLAxEx94WDwC9jRrUHnH6d8IrcLQ0o4HiB9FtLSG+JftAJyCCMfIjSsOYuADzl7l0f ayaFdy++A4WPmFEcWqKd3zzK8M4evNr8rpjVZkbliUuNxHdOymLmtcIou1M/e/80k1Sn epoygFBpSMGl3Kuc9YUzXYY8b7F7CMszItBaeqZq2DEzibprJdUANyBn9Xh5B+slFWvf 0EMx8GOA3NAlmpfB5OBIrRSe08l3khoWy7yqL/OWNA19lIPr23rEDZ0K/uF1HQb4yESV KmA6nw6aUgfwLLOYV5NQI2iZ+DAp0O4QtTLQHKUqC5GM1kh+B/FA+stU78x/m+jEgZSR 7NjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=hhXeItNmC6oOWV0ruOV86Bmq/eIGtG0OLSffa7LXxuc=; b=Ax2nawKsOl2ETx5AMgR8NhkO7LaTYxubOxkgeartbdKZjnDnRRFns1U6Qyj1eMPUeX AdsuWPbibcFMp7lApzqKqMCDJyh/8zYG26qr0yMrB3E+KSSWFx+wF/oVLRwUJUrZVGbX NHAX6H2gl8jTr8VjTB8/74rkqJSvMthui1cyIviRR842S2/ePelxQJ7HzqvLIsOlBW2w sHrTLuuSV9o6OQtjeHQ+Bi8YfXLUAyFqlRhJXHy5tCtIl4NROGQtxkX7L8MvY+Q57aBo 55SEtAjRNDy7osnNAc5KeonDtcYCT9YxF6RVwwKDXPZsh7CPySwh0mOtyAsLhkvOKV+t F3Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=hRLkS2mf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5-v6si8213191pgu.341.2018.05.19.14.04.35; Sat, 19 May 2018 14:04:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=hRLkS2mf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752575AbeESVEY (ORCPT + 99 others); Sat, 19 May 2018 17:04:24 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:37856 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752515AbeESVEV (ORCPT ); Sat, 19 May 2018 17:04:21 -0400 Received: by mail-io0-f195.google.com with SMTP id e20-v6so10198133iof.4; Sat, 19 May 2018 14:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hhXeItNmC6oOWV0ruOV86Bmq/eIGtG0OLSffa7LXxuc=; b=hRLkS2mfKVWjbNfmqccX99Xy/ZyJ4lbbHolLbZc6Z4Z1kfSACmJfq4mZ5l0lAKKLd4 Ed9G6SKN4xZoULDJ3tqw3POIRE16gITDM8VhPgTqDmYvDrleC0d0359TdJR6Z19yIQFR Ek6SRVtpbF8HI8D5mZXhEZiM4mzr3CMH9oRuw= 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=hhXeItNmC6oOWV0ruOV86Bmq/eIGtG0OLSffa7LXxuc=; b=mJXC+07wbDcC2DH8n1jMwBJx7Eko3AKblIHfDKM+dYUhWZRtdEUho84p+XGo1+Diig l2y0rfAdjmmGIYW7dcqtgSQ938B20ZmgcloBI054PtvyOLyd/pRKVGDuXu9bELmo9c5B cjluNNcx++CGEhbwfExLVjfY2MsjiJkNzB6J94641tT8i7sLbvETUdBBkji56eR/QbUa 0yAmas3uhxOJ98in3qCqT++n0l+NZS4ELLAZs/y4Rs4VBFVOPSfpjJ9a+JiQluMrNLJR 675E8sQ+0UZwUnRq3MDQX/gaAg/BjkPt2+HMckvY7kaZaCJm1cHK4MYBa0Lu7lXoKyd8 IBKw== X-Gm-Message-State: ALKqPwc5HyW860wyhtwztJIngvJyQXGRHqWJvpN/4LTwPm/g7yiCgLnE zpdNn456S1v5UhzxN0pBX+8AmJ7PwAfxzV0u3vs= X-Received: by 2002:a6b:dc12:: with SMTP id s18-v6mr16781894ioc.203.1526763860958; Sat, 19 May 2018 14:04:20 -0700 (PDT) MIME-Version: 1.0 References: <20180518130413.16997-1-roman.penyaev@profitbricks.com> <20180518130413.16997-2-roman.penyaev@profitbricks.com> In-Reply-To: From: Linus Torvalds Date: Sat, 19 May 2018 14:04:10 -0700 Message-ID: Subject: Re: [PATCH v2 01/26] rculist: introduce list_next_or_null_rr_rcu() To: Roman Pen Cc: linux-block , linux-rdma , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Bart Van Assche , Or Gerlitz , Doug Ledford , swapnil.ingle@profitbricks.com, danil.kipnis@profitbricks.com, jinpu.wang@profitbricks.com, Paul McKenney , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 19, 2018 at 1:25 PM Roman Penyaev < roman.penyaev@profitbricks.com> wrote: > Another one list_for_each_entry_rcu()-like macro I am aware of is used in > block/blk-mq-sched.c, is called list_for_each_entry_rcu_rr(): https://elixir.bootlin.com/linux/v4.17-rc5/source/block/blk-mq-sched.c#L370 > Can we do something generic with -rr semantics to cover both cases? That loop actually looks more like what Paul was asking for, and makes it (perhaps) a bit more obvious that the whole loop has to be done under the same RCU read sequence that looked up that first 'skip' entry. (Again, stronger locking than RCU is obviously also acceptable for the "look up skip entry"). But another reason I really dislike that list_next_or_null_rr_rcu() macro in the patch under discussion is that it's *really* not the right way to skip one entry. It may work, but it's really ugly. Again, the list_for_each_entry_rcu_rr() in blk-mq-sched.c looks better in that regard, in that the skipping seems at least a _bit_ more explicit about what it's doing. And again, if you make this specific to one particular list (and it really likely is just one particular list that wants this), you can use a nice legible helper inline function instead of the macro with the member name. Don't get me wrong - I absolutely adore our generic list handling macros, but I think they work because they are simple. Once we get to "take the next entry, but skip it if it's the head entry, and then return NULL if you get back to the entry you started with" kind of semantics, an inline function that takes a particular list and has a big comment about *why* you want those semantics for that particular case sounds _much_ better to me than adding some complex "generic" macro for a very very unusual special case. Linus