Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp198276pxa; Wed, 26 Aug 2020 08:18:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9n19WRYs3fkPNOelhwzWvNGjYys1VcaLBh0Yim7Iprjati+Thm254VaYFE1wHNDNSqmbR X-Received: by 2002:a17:906:6895:: with SMTP id n21mr17199785ejr.155.1598455081582; Wed, 26 Aug 2020 08:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598455081; cv=none; d=google.com; s=arc-20160816; b=IKbPNC2PfznMeghqi5g7E3w3FWJi2MLg+dUv7ey9bWlFIJBPs4k4jfqyc6qJ3MxW9Y Sca9OPnfr/JhDf1eVB4SwZPCEBUshyJiuLvmt7GyewZdPLJp6rsK89Hfa0aRXFuB18J+ 8Yl1cYJ6IPbJYr8QXZgJ+Y97iGDkftS0luYwXnHgjcYHTLSOKBgXamfWIpOcv971W7gt bupX2ac0Ac8fbAcAeuXHGtRVn7FicOXF0HPy81SWJffTjL13OlDyBWFfGm6gjYyLLzY2 cxKqLT8Ugo4UzPggb7x6jY3UuqFvm3OrTGn7eWHwhE13GKJa8SXa1bm9dkjT8pg43pi9 Ityw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CmlsOBKmXTTcSfq5zGubBNNUb0gupInXkPP8EnZ3d+A=; b=QCFkrr5DH/wMh6ykUrAF4PKVZpsYuX2cq1THHRD94FULMCuFnVd99VBMd6Le2Qgyic cntrsieK+MmcQWajyFN++E4wlp7oTptE/cKvuivKTna3hIY0oI2sEFqmMM7xdY1ayduc Hu+M5cspZDSP0npNEusL0/e5OOB/fTDojlrcqlNb/AwXoAnXM2V6XcxNGRO/VXUkj5wz 8AarE8j5L75IX3t5fMkFOsg8lVT/fJASK2vSXS5geVS2XBnsAJk5A9rDK5m1c9PjMqTQ xmW/r49KFn618w1zENRibIBYMCaUfsGOAzXV28fjWz4Q4/CTKIMJnDSZIvPRppT5bw+r HZFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZqQGx8lC; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si330494eda.380.2020.08.26.08.17.38; Wed, 26 Aug 2020 08:18:01 -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=@chromium.org header.s=google header.b=ZqQGx8lC; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728069AbgHZPNw (ORCPT + 99 others); Wed, 26 Aug 2020 11:13:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728018AbgHZPNd (ORCPT ); Wed, 26 Aug 2020 11:13:33 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48AD4C061757 for ; Wed, 26 Aug 2020 08:13:32 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id v15so1171300pgh.6 for ; Wed, 26 Aug 2020 08:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CmlsOBKmXTTcSfq5zGubBNNUb0gupInXkPP8EnZ3d+A=; b=ZqQGx8lCIpp9MgN3WVINar6Fy8irHzrpJRsjxGoHQTeWbqHYD6il/g9q7DvpK/dmQm 0qW7aVa3Tr+PGt5edZDuPZxHNjlNPlIhusw3juLIWAAlHZXHD4KNjNATv1u3ZoCJvNEC S2smx23jdqkXqQh3IP6NS4LTsP6Gm53DxBdKk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CmlsOBKmXTTcSfq5zGubBNNUb0gupInXkPP8EnZ3d+A=; b=ePiAgismGyzUO85LdXNyRrFzDxLWadlnrVxkuTTqkJU7VnYVuaERhO8+2HbjbIAA2e KCqZdeFKlBGiJiEQZ74F9AIMP5nsxD2/vW+9vrC2XezgbkckVDXo/3W0kX0OwBwIxaxJ iQHsw7VSMu28W7vujRKLUDd8Ouql/hqLQEJi/xqiHwa6ZEwv0yIedS5GvnmYktd4LYkw abziuhsV/i0g9TYV9dlRGoAM9xgL8a7qCqemaXu4oN0t7pO2vJ7ZtGojnf43K+Z4g3mp Mh19vCMl6fBOXjN6nLO7+FzSWftWELgwL4viYKbC69VUond09ZFlfNvYNVs5OzMiZyfE Ke6g== X-Gm-Message-State: AOAM530ze0olzuZiGJFIMzSjmt0eo1kb9U6H3JaW+Mn0TI1dRPi6C7gE FgTc+LWTsR8msRQNwueTvBZlAA== X-Received: by 2002:a63:f909:: with SMTP id h9mr10562477pgi.250.1598454811989; Wed, 26 Aug 2020 08:13:31 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d127sm3380122pfc.175.2020.08.26.08.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 08:13:30 -0700 (PDT) Date: Wed, 26 Aug 2020 08:13:29 -0700 From: Kees Cook To: Dan Carpenter Cc: Allen Pais , James Bottomley , Ulf Hansson , linux-atm-general@lists.sourceforge.net, manohar.vanga@gmail.com, airlied@linux.ie, linux-hyperv@vger.kernel.org, dri-devel@lists.freedesktop.org, sre@kernel.org, anton.ivanov@cambridgegreys.com, devel@driverdev.osuosl.org, linux-s390@vger.kernel.org, linux1394-devel@lists.sourceforge.net, maximlevitsky@gmail.com, richard@nod.at, deller@gmx.de, jassisinghbrar@gmail.com, linux-spi@vger.kernel.org, 3chas3@gmail.com, intel-gfx@lists.freedesktop.org, Jakub Kicinski , mporter@kernel.crashing.org, jdike@addtoit.com, oakad@yahoo.com, s.hauer@pengutronix.de, linux-input@vger.kernel.org, linux-um@lists.infradead.org, linux-block@vger.kernel.org, broonie@kernel.org, openipmi-developer@lists.sourceforge.net, mitch@sfgoth.com, linux-arm-kernel@lists.infradead.org, Jens Axboe , linux-parisc@vger.kernel.org, netdev@vger.kernel.org, martyn@welchs.me.uk, dmitry.torokhov@gmail.com, linux-mmc@vger.kernel.org, Allen , linux-kernel@vger.kernel.org, alex.bou9@gmail.com, stefanr@s5r6.in-berlin.de, Daniel Vetter , linux-ntb@googlegroups.com, Romain Perier , shawnguo@kernel.org, David Miller Subject: Re: [PATCH] block: convert tasklets to use new tasklet_setup() API Message-ID: <202008260811.1CE425B5C2@keescook> References: <161b75f1-4e88-dcdf-42e8-b22504d7525c@kernel.dk> <202008171246.80287CDCA@keescook> <1597780833.3978.3.camel@HansenPartnership.com> <1597849185.3875.7.camel@HansenPartnership.com> <1597873172.4030.2.camel@HansenPartnership.com> <20200826095528.GX1793@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200826095528.GX1793@kadam> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2020 at 12:55:28PM +0300, Dan Carpenter wrote: > On Wed, Aug 26, 2020 at 07:21:35AM +0530, Allen Pais wrote: > > On Thu, Aug 20, 2020 at 3:09 AM James Bottomley > > wrote: > > > > > > On Wed, 2020-08-19 at 21:54 +0530, Allen wrote: > > > > > [...] > > > > > > > Since both threads seem to have petered out, let me suggest in > > > > > > > kernel.h: > > > > > > > > > > > > > > #define cast_out(ptr, container, member) \ > > > > > > > container_of(ptr, typeof(*container), member) > > > > > > > > > > > > > > It does what you want, the argument order is the same as > > > > > > > container_of with the only difference being you name the > > > > > > > containing structure instead of having to specify its type. > > > > > > > > > > > > Not to incessantly bike shed on the naming, but I don't like > > > > > > cast_out, it's not very descriptive. And it has connotations of > > > > > > getting rid of something, which isn't really true. > > > > > > > > > > Um, I thought it was exactly descriptive: you're casting to the > > > > > outer container. I thought about following the C++ dynamic casting > > > > > style, so out_cast(), but that seemed a bit pejorative. What about > > > > > outer_cast()? > > > > > > > > > > > FWIW, I like the from_ part of the original naming, as it has > > > > > > some clues as to what is being done here. Why not just > > > > > > from_container()? That should immediately tell people what it > > > > > > does without having to look up the implementation, even before > > > > > > this becomes a part of the accepted coding norm. > > > > > > > > > > I'm not opposed to container_from() but it seems a little less > > > > > descriptive than outer_cast() but I don't really care. I always > > > > > have to look up container_of() when I'm using it so this would just > > > > > be another macro of that type ... > > > > > > > > > > > > > So far we have a few which have been suggested as replacement > > > > for from_tasklet() > > > > > > > > - out_cast() or outer_cast() > > > > - from_member(). > > > > - container_from() or from_container() > > > > > > > > from_container() sounds fine, would trimming it a bit work? like > > > > from_cont(). > > > > > > I'm fine with container_from(). It's the same form as container_of() > > > and I think we need urgent agreement to not stall everything else so > > > the most innocuous name is likely to get the widest acceptance. > > > > Kees, > > > > Will you be sending the newly proposed API to Linus? I have V2 > > which uses container_from() > > ready to be sent out. > > I liked that James swapped the first two arguments so that it matches > container_of(). Plus it's nice that when you have: > > struct whatever *foo = container_from(ptr, foo, member); > > Then it means that "ptr == &foo->member". I'm a bit stalled right now -- the merge window was keeping me busy, and this week is the Linux Plumbers Conference. This is on my list, but I haven't gotten back around to it. If you want, feel free to send the container_from() patch; you might be able to unblock this faster than me right now. :) -Kees -- Kees Cook