Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1253740imm; Fri, 29 Jun 2018 14:27:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe9r5MdPZ9mTFOndOptsvvIPISaQKnpsmiMWqorfwBv5ipH9Vmhs0VT3gghCXZdsDxqlSWl X-Received: by 2002:aa7:80cf:: with SMTP id a15-v6mr16026206pfn.19.1530307632441; Fri, 29 Jun 2018 14:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530307632; cv=none; d=google.com; s=arc-20160816; b=LEsM1RmUUeVilynX1iMJZrwQh52G67ldQZyZ541if5rWpJUQjKhk4VxpEoBxe3huUC Rh0CF6ngGqU+7TRPyOGuFnhKsoElQBxGtcZLY7oGi9u0sxcBINptYncFW1pJPvY1ehIU GQg8jnihueWDiL6lmx0G/t1hq0GT6i8bnQ3um3nBEWpPffBAYPzw7imFGxAXDTCSkbxS JMElw3+LzRzHA3XQXwGZ36MNsRxRtC/LoELvSIsuVESfSL2SVapmp8TtXsix1yhjtdKJ NujmAuHtk3FHDVBbinBk0zfR11athLGM095lNa7Mg4qlCHuYQ/4DNVAC2SUSN3g3zSJ2 9JIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=RfDGfnl3W3Ys8sNvt7aW4oVStiCBWU5ZGhw6jP2bn1U=; b=mRwiF3b2Q5vEoF1Csf8nav/PnjDvsiKIKdWfEPy52H2jyXmzji98K20hqY7Yk9yttT B/rM081BL4poMDEGVooEiRG710Y0HiMZwz14QOvCXCuXNcJQxW/zWHWu02CzuBjNZvef 52pPSJ6Jfz/6+e63FK/3tl5qT78kzshNFJiOpeqVmFgGE1+Twq/zEvrLSwd1WxOnAOjk ExHIId0RAXfkAN9gkrSBuXBHP9Smqg06Y3EQfY1VuwC10FSs6Tsue6SIEHgzNKpjkV6K cruYwCMUkzoq+yGpZeyYFA7dyBqnxhE8zRMCGQKAfI8DTpP0ZCV6d8KlqK0NxZWqgSoW eALw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=JvCFt7eA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10-v6si10326839pfh.119.2018.06.29.14.26.58; Fri, 29 Jun 2018 14:27:12 -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=@oracle.com header.s=corp-2017-10-26 header.b=JvCFt7eA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936516AbeF2VU0 (ORCPT + 99 others); Fri, 29 Jun 2018 17:20:26 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:34818 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934360AbeF2VUY (ORCPT ); Fri, 29 Jun 2018 17:20:24 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5TLEFZ0048877; Fri, 29 Jun 2018 21:20:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=RfDGfnl3W3Ys8sNvt7aW4oVStiCBWU5ZGhw6jP2bn1U=; b=JvCFt7eAoYWFJuu4EoyOgP4y8f+qDqOcFsBd1cDZZs2eCqs8iwGerz5bvHblu2docA+y PfTxcKZqny9c6vjp5GvIX+/shzGSGihZ6ciLXHDL0XFi8B1Gi40QiffRzARIo6YeS6T2 /mk7JENokWLhhMkqGWOu0YRNEKNpCZlBlRYdPhEX8J4pU5YjkT2qCAJjwLLLozXsLH2C /5ScJ4zB8qodPt4W+wGFvqmsFIq1OALTvksRZp6GWAImPEmNFAZdAh4thhPwMadMZu9L yBFhYzEXBi+YUKkILhHE3wsC9LJPGWUbmfljKn/y3Lshh0NxCEhZ4hQbx5j1E3SjlnBR lA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2jukhsr3pg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jun 2018 21:20:19 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5TLKJE7028504 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jun 2018 21:20:19 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5TLKI7W023224; Fri, 29 Jun 2018 21:20:18 GMT Received: from [192.168.1.10] (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 29 Jun 2018 14:20:18 -0700 Subject: Re: [PATCH v6 2/3] drivers core: prepare device_shutdown for multi-threading To: Andy Shevchenko Cc: Steven Sistare , Daniel Jordan , Linux Kernel Mailing List , "Kirsher, Jeffrey T" , intel-wired-lan@lists.osuosl.org, netdev , Greg Kroah-Hartman , Alexander Duyck , tobin@apporbit.com References: <20180629182541.6735-1-pasha.tatashin@oracle.com> <20180629182541.6735-3-pasha.tatashin@oracle.com> From: Pavel Tatashin Message-ID: Date: Fri, 29 Jun 2018 17:20:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8939 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=872 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806290225 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/29/2018 04:38 PM, Andy Shevchenko wrote: > On Fri, Jun 29, 2018 at 9:25 PM, Pavel Tatashin > wrote: >> Do all the necessary refactoring to prepare device_shutdown() logic to >> be multi-threaded. >> >> Which includes: >> 1. Change the direction of traversing the list instead of going backward, >> we now go forward. >> 2. Children are shutdown recursively for each root device from bottom-up. >> 3. Functions that can be multi-threaded have _task() in their name. > >> +/* >> + * device_children_count - device children count >> + * @parent: parent struct device. >> + * >> + * Returns number of children for this device or 0 if none. >> + */ >> +static int device_children_count(struct device *parent) >> +{ >> + struct klist_iter i; >> + int children = 0; >> + >> + if (!parent->p) >> + return 0; >> + >> + klist_iter_init(&parent->p->klist_children, &i); >> + while (next_device(&i)) >> + children++; >> + klist_iter_exit(&i); >> + >> + return children; >> +} > > Looking at another patch in LKML (for gluedir children counting) I > would suggest to consider to cache children value. > Would it make sense? > > (So, basically you would update that value on children registered / removed) > Hi Andy, Thank you for looking at this patch. For this particular series, this function is called only once per device during shutdown, when nothing else is running on the machine. So, caching won't really provide us any improvement. If, in the future this function is going to be called from other sites during run-time of the machine, then yes, that would mean that caching might help. Thank you, Pavel