From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4242VL42SQzF35w for ; Tue, 4 Sep 2018 07:02:50 +1000 (AEST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w83HsACl080433 for ; Mon, 3 Sep 2018 13:55:01 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2m98jw28k9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 03 Sep 2018 13:55:00 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Sep 2018 18:54:58 +0100 Date: Mon, 3 Sep 2018 19:54:49 +0200 (CEST) From: Sebastian Ott To: Lukas Wunner cc: Bjorn Helgaas , linux-pci@vger.kernel.org, Sinan Kaya , Mika Westerberg , "Rafael J. Wysocki" , Len Brown , Scott Murray , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Gavin Shan , Sebastian Ott , Gerald Schaefer , Corentin Chary , Darren Hart , Andy Shevchenko , Greg Kroah-Hartman , linux-acpi@vger.kernel.org, linux-s390@vger.kernel.org, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 8/9] PCI: hotplug: Embed hotplug_slot In-Reply-To: <9918fbca94bcfc03d1560b191d138d3e6664cc86.1534686485.git.lukas@wunner.de> References: <9918fbca94bcfc03d1560b191d138d3e6664cc86.1534686485.git.lukas@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Sun, 19 Aug 2018, Lukas Wunner wrote: > When the PCI hotplug core and its first user, cpqphp, were introduced in > February 2002 with historic commit a8a2069f432c, cpqphp allocated a slot > struct for its internal use plus a hotplug_slot struct to be registered > with the hotplug core and linked the two with pointers: > https://git.kernel.org/tglx/history/c/a8a2069f432c > > Nowadays, the predominant pattern in the tree is to embed ("subclass") > such structures in one another and cast to the containing struct with > container_of(). But it wasn't until July 2002 that container_of() was > introduced with historic commit ec4f214232cf: > https://git.kernel.org/tglx/history/c/ec4f214232cf > > pnv_php, introduced in 2016, did the right thing and embedded struct > hotplug_slot in its internal struct pnv_php_slot, but all other drivers > cargo-culted cpqphp's design and linked separate structs with pointers. > > Embedding structs is preferrable to linking them with pointers because > it requires fewer allocations, thereby reducing overhead and simplifying > error paths. Casting an embedded struct to the containing struct > becomes a cheap subtraction rather than a dereference. And having fewer > pointers reduces the risk of them pointing nowhere either accidentally > or due to an attack. > > Convert all drivers to embed struct hotplug_slot in their internal slot > struct. The "private" pointer in struct hotplug_slot thereby becomes > unused, so drop it. > > Signed-off-by: Lukas Wunner > Cc: Rafael J. Wysocki > Cc: Len Brown > Cc: Scott Murray > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: Gavin Shan > Cc: Sebastian Ott > Cc: Gerald Schaefer > Cc: Corentin Chary > Cc: Darren Hart > Cc: Andy Shevchenko for s390_pci_hpc.c: Acked-by: Sebastian Ott