Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp219637pxb; Tue, 2 Feb 2021 03:33:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwe3PkQ9J0J4NwCb45xqFpoigoeFxNY1LpGE3V7aDnS+0dT/Ap4mNYgNAa2VfzdFTInG/z9 X-Received: by 2002:a17:906:2a06:: with SMTP id j6mr21191149eje.164.1612265595108; Tue, 02 Feb 2021 03:33:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612265595; cv=none; d=google.com; s=arc-20160816; b=OrcRrt8AviNpwROEE7ZM5zU57nedcoQnw9T7sx/goqiy93bekfoEquTvDG4TywRt/+ 41dJrFYFws+hvwvWfrvuZkz+q3pd3GFQ5yey4zTlYYuW15xtkai1PWwLxVpc6pmWF5Dl EoOnpfaRWhtKoJXWhSPMBFsjsF2qrr2G4Wwd8EUzZWbKkcxvtLRi+6dnGAvGhQ/px0iu fdPKXRxAAk9ewqs2ocj1i47kBVgeBmtuvh4eRRjZ1DRen0uKuzDvMBEd9l4HMqku68+0 ApocKDmK+2K8dfdtG66hPd3UfX/hyQba2M6fc12CmcZ6ta6Hv3ROyT7ZhpYUfhuQUHRD i6rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=O8FfoCYCl+VsulMAjxIFNzj447KzN3RHZtnX449atCE=; b=O31utWnc6uCN3BXn4C5q6lNMyXD0Yb9oG0mtWxgcMB7g5AOVAnaOXMPsmqBBPBKuOJ a4PlDwk4Opo9CwUgI9lEb2vnlHIlbjIO0g/PDoMoW3mFHMKxDJ8Jhhb7Sbqx3I2Od//I QwGoRJ5I7Wgci0mHJLYa0KKyWVVG1smT9Xldo2i8khtrgLQ4lzJYDiGB05k7x4+B9PAG 8joVXYALQMRVyJ6LbtskPKmQLI7ZNP8h1AXvHJ3RXedO0O6BNb6DG/Lzea3g7ll9XjlA LYDY9pkUDNcWOis+R12Dey8+eYy8+Qp75hB8r4yow7cyh1wGKa2Tfs/VC6/UGVI+nh+F zh+A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o19si13391704edz.565.2021.02.02.03.32.49; Tue, 02 Feb 2021 03:33:15 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231406AbhBBLbp (ORCPT + 99 others); Tue, 2 Feb 2021 06:31:45 -0500 Received: from mga17.intel.com ([192.55.52.151]:6959 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbhBBL3e (ORCPT ); Tue, 2 Feb 2021 06:29:34 -0500 IronPort-SDR: Mfg/488EZG1NsiXVMVGwbHvLj29W8WOYlWqewBIsz83yGGVMvRAYZC7J62+9bJmDdvYcO3YXe/ 928gBCh2FJJA== X-IronPort-AV: E=McAfee;i="6000,8403,9882"; a="160603654" X-IronPort-AV: E=Sophos;i="5.79,394,1602572400"; d="scan'208";a="160603654" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2021 03:27:43 -0800 IronPort-SDR: 2Rc0Ikw4v3gdbwgcJwco0+nR1oatilf8/ryPGdXG7K+2H+4ey6rP6I8ScbsETZ+vR3T1kOCBEy GN/VDhaWLS0Q== X-IronPort-AV: E=Sophos;i="5.79,394,1602572400"; d="scan'208";a="370573944" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2021 03:27:39 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1l6tqK-001NPV-2X; Tue, 02 Feb 2021 13:27:36 +0200 Date: Tue, 2 Feb 2021 13:27:36 +0200 From: Andy Shevchenko To: Daniel Scally Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , ACPI Devel Maling List , linux-gpio@vger.kernel.org, linux-i2c , Platform Driver , "open list:ACPI COMPONENT ARCHITECTURE (ACPICA)" , "Rafael J. Wysocki" , Len Brown , andy@kernel.org, Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Wolfram Sang , Lee Jones , Hans de Goede , Mark Gross , Robert Moore , Erik Kaneda , Sakari Ailus , Laurent Pinchart , Kieran Bingham Subject: Re: [PATCH v2 2/7] acpi: utils: Add function to fetch dependent acpi_devices Message-ID: References: <85ccf00d-7c04-b1da-a4bc-82c805df69c9@gmail.com> <0fac24d2-e8fc-7dc8-0f2f-44c7aadb1daf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 02, 2021 at 09:58:17AM +0000, Daniel Scally wrote: > On 21/01/2021 21:06, Daniel Scally wrote: > > On 21/01/2021 18:08, Rafael J. Wysocki wrote: ... > > No problem;? I'll tweak that then > > Slightly walking back my "No problem" here; as I understand this there's > kinda two options: > > 1. Walk over the (locked) list, when a match is found unlock, run the > callback and re-lock. > > The problem with that idea is unless I'm mistaken there's no guarantee > that the .next pointer is still valid then (even using the *_safe() > methods) because either the next or the next + 1 entry could have been > removed whilst the list was unlocked and the callback was being ran, so > this seems a little unsafe. It's easy to solve. See an example in deferred_probe_work_func(). https://elixir.bootlin.com/linux/latest/source/drivers/base/dd.c#L75 > 2. Walk over the (locked) list twice, the first time counting matching > entries and using that to allocate a temporary buffer, then walk again > to store the matching entries into the buffer. Finally, run the callback > for everything in the buffer, free it and return. > > Obviously that's a lot less efficient than the current function, which > isn't particularly palatable. > > Apologies if I've missed a better option that would work fine; but > failing that do you still want me to go ahead and change > acpi_walk_dep_device_list() to do this (I'd choose #2 of the above), or > fallback to using acpi_dev_get_next_dependent_dev() described above? If > the latter, does acpi_walk_dep_device_list() maybe need re-naming to > make clear it's not a generalised function? -- With Best Regards, Andy Shevchenko