Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1247426imm; Fri, 29 Jun 2018 14:18:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJLJVuyC36mjACLP3xbcjnBt/a6J/3+/4ydUV3vyQl5phRoLpwPrmX2VFL4iDX0ErOSAOI6 X-Received: by 2002:a17:902:e3:: with SMTP id a90-v6mr16776795pla.227.1530307089049; Fri, 29 Jun 2018 14:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530307089; cv=none; d=google.com; s=arc-20160816; b=cYF0cfTrrzRqpKzjsCDVsxGK8AIXlJTdEBysg5/rmMCDo5Zm9MakfUbAxVYiMI5w1S Tbq4pCXYLKcCZviY7oBL86OORGXlezwmCgQE8RwbCu6pn2sCuGFx516sXdPkklFfgyyZ ZzkwYkeLeEx+2t87TH88oU/zBdmce7mhrSgQtpN31yHDcRK67T5UrlulSPAIft1X50xq 8Mr9lhIloI1uS29HF8TEhSc+I0E//4nIlWkjuy8Scy73e8twMHvJ96XA42kFyZNLd/5b uPFcpPUXPhynaXXdqjLjUZ8aXGzImCfLEPgEyM1xPf1WokH6e+aG8z8SdSzDe4UdaUPq E7SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ezubZYHDD0tYZ9v6z+xObLDAXWgSFAiQKJ+czgNxrhk=; b=nDHlEBOysnVaABaxvCo/1p++kG1WemekaqEVKkhxY+Ps+A7v/VcT0goQvj2v7+Jc1d bIrFHkUFyqhHFu+Zi6eZvk7DfZH7i6pbak5oap6oJpmVsp9zD2u1gvNP+BOITi2UwW0L Yb+tD0WBsf5CJHmuzI8ILua4iWHF4jlP/ljpBo9SmM2Ki6VupD7vqZsAIQunag0vvGu3 LlWNoT8w3PHtcR+gqRdYa66iTzgQMwdOY34eDiX801PT2PoOLA+FOz6ry8LH8s8ZI28i H8wiI+rihE/tdezNK5dDkswZu9kQCR7I6Up0YAAvcfogqC4fm6uCV+EV0ERZJQu9xIIB eDtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eS4CQgV6; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g63-v6si9006457pgc.151.2018.06.29.14.17.54; Fri, 29 Jun 2018 14:18:09 -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=@gmail.com header.s=20161025 header.b=eS4CQgV6; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755595AbeF2UiV (ORCPT + 99 others); Fri, 29 Jun 2018 16:38:21 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:39260 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753148AbeF2UiR (ORCPT ); Fri, 29 Jun 2018 16:38:17 -0400 Received: by mail-ua0-f194.google.com with SMTP id n4-v6so6574026uad.6; Fri, 29 Jun 2018 13:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ezubZYHDD0tYZ9v6z+xObLDAXWgSFAiQKJ+czgNxrhk=; b=eS4CQgV6m7qDE6UulQtLgPfKqQgdVD5ft/RjKRSYg+OGg8ziYR77hXlD7Sqx2yV3Fz rFGFWys9WxRkxFMYHbwRhACEkLPgEIYEh4hEppaJFApP8z9HWBCBdnfXEvfPrDrwxRVP bIoS48hsBCUirZyjqzWuS1yjsRC1XWAV9MTwSJQmcdu/mWdVuuwCYATPlOdL5Phlp7vm H0CpTfiL3IZWjXe5hSymi34czh8eHeyErF4vqMGUoPr7HVUJXwe0xs7la9xoPwcHUpuW HrD57egYoc36+slTMcORhkE6/3wOmxMNOG4JuGW3ysxW1Wb1Q4D2qC4ysPW4soqO4AbC wIKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ezubZYHDD0tYZ9v6z+xObLDAXWgSFAiQKJ+czgNxrhk=; b=LoYxZMB/av4piQOwlry5dSfVTfrfH4GxtMtWm+9YcfqbyEA7SBRJBhiM1A2Tnfp9VD nPp0a9H9ZRdXigos+5x950gnVXYfWWbC0iHXdTbO9EKYLbhP6VnHdHba7D5usTl5dykj DJaoaIwN6pnVmaT6ABO8ZBiGJS7nVgaBBWCZWreC4QKiAkoMqWyhf+o3p6rDnOD1Cg5E +j+YLWzTGDRYi7SK+w3xcXy7JhhS8pTTI4Rg9Scqaa7cUzY4Na2Ww1w7rrRX1yPxWpLZ nAfc9I5wT6HHbb5XPPxBNcmxinBwX2EK/GE4CPDNN7tnwyZl2rWyIfcNbLdjrQCWDRcV VeyA== X-Gm-Message-State: APt69E2m7Nm1MeEq3g4W5I7hjPnmNX/1gXcfRL6TFX+fV8YRkwds6Qs2 nr6R5VQXhluc97HhsKo8NJhSFd307TrhbUYKlIE= X-Received: by 2002:a9f:3613:: with SMTP id r19-v6mr10571355uad.49.1530304696895; Fri, 29 Jun 2018 13:38:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:8b02:0:0:0:0:0 with HTTP; Fri, 29 Jun 2018 13:38:16 -0700 (PDT) In-Reply-To: <20180629182541.6735-3-pasha.tatashin@oracle.com> References: <20180629182541.6735-1-pasha.tatashin@oracle.com> <20180629182541.6735-3-pasha.tatashin@oracle.com> From: Andy Shevchenko Date: Fri, 29 Jun 2018 23:38:16 +0300 Message-ID: Subject: Re: [PATCH v6 2/3] drivers core: prepare device_shutdown for multi-threading To: Pavel Tatashin 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- With Best Regards, Andy Shevchenko