Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5063406imm; Mon, 14 May 2018 18:53:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrHUrpjUCMXwFekgj6ppVOTL41m/RgPe02iXGDFdnnmIe5N04xTi7QQqhvQGXuKzRYvn7S5 X-Received: by 2002:a62:e04c:: with SMTP id f73-v6mr12904652pfh.88.1526349223902; Mon, 14 May 2018 18:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526349223; cv=none; d=google.com; s=arc-20160816; b=QgywfgC80oVZZgaN61rK6kqb9oT4sKixejTKODoRt0lxDWvG/8XYatO1ylrlW7p0BK f6TMW/WA6zuZEEMCb2verBAwd+0AbUnI2YN/hixb+XAH0hwV9JNCwmXPRAG0Oiy2DLQ4 jj+yIjBBwvkq2QKFudgGASMT9sreTEu9K68WMioZxDP7lS+uEJYbozuK+dtVtjnHE9yr k4+xSmLdzTcRz7hl2syj5j+9IQo41on82Egba4rOkjutyJ8Ri9Gir1gC8+gBR8Dke+zk VS6dqvPWdwQrbp4UtuhWn3hwpaOWPj49sOtM+C4Qmd7WTsssawtb185rSBCxbulQaY18 y6tQ== 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=fiT2gC8mOXb1gHFNa8Hhtq58TMgikU9O7j0E5H1sJIc=; b=oA3e446lCfX4C8Yc8pLVzLAXCAuGvi/ZiJxCIrI1xmXCn4XOSwnAzzxdEbeh3UNTLn n99MKEvQkv4eiMngUvmkYgE2DeENT8iTHJjvCQs9EgFj7gt4wAI7Gor58YFVv1XFvQQG eZG+FS+lwaHD1sBI0sm4tLqjtCHfW5FKcDq84RBikcVK1biI80DEcOHAAbrTWoXHYH8O f53qmktdw7XRaaFw/hxce/+1PetcqUQcLjSCrLJlnbaEc25ifoKS9ZsrriH4hhwZbvmy LUJUBZOWRC5rVAURk149ZU213tqd6l5pN4M+waGKkadSAvtwpt+eyYjFmha9t9tgrwIN 4bog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=gIFe+hJS; 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 n3-v6si10485466plp.550.2018.05.14.18.53.29; Mon, 14 May 2018 18:53:43 -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=gIFe+hJS; 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 S1752462AbeEOBxW (ORCPT + 99 others); Mon, 14 May 2018 21:53:22 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:52396 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752094AbeEOBxU (ORCPT ); Mon, 14 May 2018 21:53:20 -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 w4F1rDb9172907; Tue, 15 May 2018 01:53:13 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=fiT2gC8mOXb1gHFNa8Hhtq58TMgikU9O7j0E5H1sJIc=; b=gIFe+hJSEHwmq5djxxyBJ1E2S+9oz4O2MEaFkITUU1ahLnf6pgdiL5anH7Ut3rhHwe7A 2LY8Ago0cezQTE+d3dyjS8LYRHvW53MI0VobxR7/e0W/uiHjN8Rb4Kl0G0DM6S2uxcDJ B1rsvJNR/g1Op3o481WBscqYkUJhHtA6LhnaNJsD1MZ7Es8iOp+3fWE3LvmoLMDBo8rS PoSvxCoQoiYt5eML0irTUryBqMLij5w9mjQHzMIy6Yb8U/QvsfiNpP46loT8/3tyiVHf H4EsfgBnGETKDo21gGeAh+9varPbGN+Iva45bTfB7Uxf8OAB1fo4c2bB0VctaN49ElrH ew== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2hx29vxbrb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 May 2018 01:53:13 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w4F1rCIP004176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 May 2018 01:53:12 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w4F1rCgD031699; Tue, 15 May 2018 01:53:12 GMT Received: from [10.39.255.157] (/10.39.255.157) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 14 May 2018 18:53:11 -0700 Subject: Re: [PATCH v4 1/1] drivers core: multi-threading device shutdown 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@gmail.com, tobin@apporbit.com References: <20180514194254.14748-1-pasha.tatashin@oracle.com> <20180514194254.14748-2-pasha.tatashin@oracle.com> From: Pavel Tatashin Message-ID: <2d3c80ee-f990-0619-8107-7a0cb4c76f04@oracle.com> Date: Mon, 14 May 2018 21:53:02 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.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=8893 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805150016 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, Thank you for your comments. I will send an updated patch soon. My replies are below: On 05/14/2018 04:04 PM, Andy Shevchenko wrote: > Can we still preserve an order here? (Yes, even if the entire list is > not fully ordered) > In the context I see it would go before netdevice.h. Sure, I will move kthread.h. >> +static struct device * >> +device_get_child_by_index(struct device *parent, int index) >> +{ >> + struct klist_iter i; >> + struct device *dev = NULL, *d; >> + int child_index = 0; >> + >> + if (!parent->p || index < 0) >> + return NULL; >> + >> + klist_iter_init(&parent->p->klist_children, &i); >> + while ((d = next_device(&i))) { >> + if (child_index == index) { >> + dev = d; >> + break; >> + } >> + child_index++; >> + } >> + klist_iter_exit(&i); >> + >> + return dev; >> +} > > This can be implemented as a subfunction to device_find_child(), can't it be? Yes, but that would make it very inefficient to search for an index in a list via function pointer call. > >> +/** > > Hmm... Why it's marked as kernel doc while it's just a plain comment? > Same applies to the rest of similar comments. Fixed this, thanks! > >> + for (i = 0; i < children_count; i++) { >> + if (device_shutdown_serial) { >> + device_shutdown_child_task(&tdata); >> + } else { >> + kthread_run(device_shutdown_child_task, >> + &tdata, "device_shutdown.%s", >> + dev_name(dev)); >> + } >> + } > > Can't we just use device_for_each_child() instead? No, at least without doing some memory allocation. Notice in this loop we are not traversing through children, instead we are starting number of children threads, and each thread finds a child to work on. Otherwise we would have to pass child pointer via argument, and we would need to keep that argument in some memory. Pavel