Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp241083imm; Tue, 15 May 2018 00:38:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpfIwAo7w3uW4R2/DW6LOsHp+4646SjlieSQm5zT4kTS3Mf0uh1I0Pha83c299ouH3UgFfh X-Received: by 2002:a63:696:: with SMTP id 144-v6mr11425277pgg.212.1526369913991; Tue, 15 May 2018 00:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526369913; cv=none; d=google.com; s=arc-20160816; b=t7owtVvJlWoljKXz2q9V91Hnf29ZwT12QKdOK11/BmQMNzTO79iQDNHwhTf8Gwq9jR t2KcN3olcgumRwglE5yb8M/HFzPfulAaQnKRP6XPy1LoYueRk49lz36nEO1TxzT9eb4b kDbQN1RliXWBU21zQagUL2/qA4ErHqmXmbhSuYQaKTGvob0OYuWQCRhvf7CgcKIR1YEm qz471iYQDNPmvZ6vDAKiILOOa0uv4+F8RahNbPibgbY9FMuXEXFG/d9LQbP2FsNPT6FD dywffYiy7y+UbEfSRyiyO4vcyLLNqgyVhYt+Q6B7YjkZ4nOvq+5IkvOB8Im24Fd3A47z +AaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=24mPbsTXemBNvzBYftqYy/9MT08GHpfrKi1NtSfPDiU=; b=wZugowsLW1z0e5Qy7JDGz7iBy7S7HM3ZOMwfXBYStpFj3kLn/3xr6MRKsBzCdMLF9C H7ota8dw0QKbJy3UsD624m3beTgNU9flZ19HJzIEqEXx2RNM6zeuA0boHxykHY6748qz 4KKkBB5fUGFiOvYfmO4IB8vYAZHdOBp4zePbL7q4ru+/V62ZtgJHkP69OHY3FHsYEmoj HCYO+Qhy01p8jtnViExidmsG5VXQOpOcLNZS2oHlfogDIcUIIlYGhw/o6TM/AVkk5JCC wTJfogVqWkb3CPgDhzV70hcgfUsgPInQLTa27YSR8GgVoSG8kGxXFLr9Qe3f97S3Y4GP 0kBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I4q7zsex; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6-v6si10888370plq.382.2018.05.15.00.38.19; Tue, 15 May 2018 00:38:33 -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=@kernel.org header.s=default header.b=I4q7zsex; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752297AbeEOHiC (ORCPT + 99 others); Tue, 15 May 2018 03:38:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:60992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752044AbeEOHiB (ORCPT ); Tue, 15 May 2018 03:38:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 44CE521746; Tue, 15 May 2018 07:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526369880; bh=8wO6iHRAW8x8bslX/I7ysrDnFVvaC9zLS1+j+VBoJ2E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I4q7zsex6jmI1hHICLprIB5cuP9JTzP/8XEHHYhS7/CMO7NJgYsYwxLXRT2AxVGRX Hl9SQjseXdUSCgnaE9IerDDMnpYWRzAjlBffzzRLOXaFoIfnGSBuTcFc8mhpN9+GDs jyssSX4DfaOAtENqqH0Ra+p2S3IFYGXSvk4VemyA= Date: Tue, 15 May 2018 09:37:44 +0200 From: Greg KH To: Pavel Tatashin Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, jeffrey.t.kirsher@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, alexander.duyck@gmail.com, tobin@apporbit.com Subject: Re: [PATCH v4 1/1] drivers core: multi-threading device shutdown Message-ID: <20180515073744.GA28338@kroah.com> References: <20180514194254.14748-1-pasha.tatashin@oracle.com> <20180514194254.14748-2-pasha.tatashin@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180514194254.14748-2-pasha.tatashin@oracle.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 14, 2018 at 03:42:54PM -0400, Pavel Tatashin wrote: > When system is rebooted, halted or kexeced device_shutdown() is > called. > > This function shuts down every single device by calling either: > > dev->bus->shutdown(dev) > dev->driver->shutdown(dev) > > Even on a machine with just a moderate amount of devices, device_shutdown() > may take multiple seconds to complete. This is because many devices require > a specific delays to perform this operation. > > Here is a sample analysis of time it takes to call device_shutdown() on a > two socket Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz machine. > > device_shutdown 2.95s > ----------------------------- > mlx4_shutdown 1.14s > megasas_shutdown 0.24s > ixgbe_shutdown 0.37s x 4 (four ixgbe devices on this machine). > the rest 0.09s > > In mlx4 we spent the most time, but that is because there is a 1 second > sleep, which is defined by hardware specifications: > mlx4_shutdown > mlx4_unload_one > mlx4_free_ownership > msleep(1000) > > With megasas we spend a quarter of a second, but sometimes longer (up-to > 0.5s) in this path: > > megasas_shutdown > megasas_flush_cache > megasas_issue_blocked_cmd > wait_event_timeout > > Finally, with ixgbe_shutdown() it takes 0.37 for each device, but that time > is spread all over the place, with bigger offenders: > > ixgbe_shutdown > __ixgbe_shutdown > ixgbe_close_suspend > ixgbe_down > ixgbe_init_hw_generic > ixgbe_reset_hw_X540 > msleep(100); 0.104483472 > ixgbe_get_san_mac_addr_generic 0.048414851 > ixgbe_get_wwn_prefix_generic 0.048409893 > ixgbe_start_hw_X540 > ixgbe_start_hw_generic > ixgbe_clear_hw_cntrs_generic 0.048581502 > ixgbe_setup_fc_generic 0.024225800 > > All the ixgbe_*generic functions end-up calling: > ixgbe_read_eerd_X540() > ixgbe_acquire_swfw_sync_X540 > usleep_range(5000, 6000); > ixgbe_release_swfw_sync_X540 > usleep_range(5000, 6000); > > While these are short sleeps, they end-up calling them over 24 times! > 24 * 0.0055s = 0.132s. Adding-up to 0.528s for four devices. Also we have > four msleep(100). Totaling to: 0.928s > > While we should keep optimizing the individual device drivers, in some > cases this is simply a hardware property that forces a specific delay, and > we must wait. > > So, the solution for this problem is to shutdown devices in parallel. > However, we must shutdown children before shutting down parents, so parent > device must wait for its children to finish. > > With this patch, on the same machine devices_shutdown() takes 1.142s, and > without mlx4 one second delay only 0.38s > > This feature can be optionally disabled via kernel parameter: > device_shutdown_serial. When booted with this parameter, device_shutdown() > will shutdown devices one by one. > > Signed-off-by: Pavel Tatashin > --- > drivers/base/core.c | 292 ++++++++++++++++++++++++++++++++++++-------- > 1 file changed, 242 insertions(+), 50 deletions(-) Can you refactor this to be at least 2 patches? One that moves code around to comon functions to make the second patch, that adds the new functionality, easier to review and understand? And I echo the "don't use kerneldoc for static functions" review comment, that's not needed at all. thanks, greg k-h