Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757254AbcLPHpW (ORCPT ); Fri, 16 Dec 2016 02:45:22 -0500 Received: from mx2.suse.de ([195.135.220.15]:52619 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428AbcLPHpO (ORCPT ); Fri, 16 Dec 2016 02:45:14 -0500 Date: Fri, 16 Dec 2016 08:41:42 +0100 From: "Luis R. Rodriguez" To: "Luis R. Rodriguez" Cc: Kees Cook , shuah@kernel.org, Jessica Yu , Rusty Russell , Arnd Bergmann , "Eric W. Biederman" , Dmitry Torokhov , Arnaldo Carvalho de Melo , Jonathan Corbet , martin.wilck@suse.com, Michal Marek , Petr Mladek , hare@suse.com, rwright@hpe.com, Jeff Mahoney , DSterba@suse.com, fdmanana@suse.com, neilb@suse.com, rgoldwyn@suse.com, subashab@codeaurora.org, Heinrich Schuchardt , Aaron Tomlin , mbenes@suse.cz, "Paul E. McKenney" , Dan Williams , Josh Poimboeuf , "David S. Miller" , Ingo Molnar , Andrew Morton , Linus Torvalds , linux-kselftest@vger.kernel.org, "linux-doc@vger.kernel.org" , LKML Subject: Re: [RFC 01/10] kmod: add test driver to stress test the module loader Message-ID: <20161216074142.GC13946@wotan.suse.de> References: <20161208184801.1689-1-mcgrof@kernel.org> <20161208184801.1689-2-mcgrof@kernel.org> <20161213211041.GO1402@wotan.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161213211041.GO1402@wotan.suse.de> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2704 Lines: 58 On Tue, Dec 13, 2016 at 10:10:41PM +0100, Luis R. Rodriguez wrote: > On Thu, Dec 08, 2016 at 12:24:35PM -0800, Kees Cook wrote: > > On Thu, Dec 8, 2016 at 10:47 AM, Luis R. Rodriguez wrote: > > > 3) finit_module() consumes quite a bit of memory. > > > > Is this due to reading the module into kernel memory or something else? > > Very likely yes, but to be honest I have not had chance to instrument too > carefully, its TODO work :) I've checked and the issue is since get_fs_type() does not check for aliases we end up hammering tons of module requests, this in turn is an analysis on load_module(). Within there layout_and_allocate() uses first a local copy of the passed user data and mapping it into a struct module, after a bit of sanity checks it finally allocates a copy for us, so its struct module size * however many requests were allowed to get in for load_module(). We could simply avoid an allocation if the module is already present. I have this as another optimization now but am running many other tests to compare performance. > > > +# Once tese are enabled please leave them as-is. Write your own test, > > > +# we have tons of space. > > > +kmod_test_0001 > > > +kmod_test_0002 > > > +kmod_test_0003 > > > +kmod_test_0004 > > > +kmod_test_0005 > > > +kmod_test_0006 > > > +kmod_test_0007 > > > + > > > +#kmod_test_0008 > > > +#kmod_test_0009 > > > > While it's documented in the commit log, I think a short note for each > > disabled test should be added here too. > > Will do, thanks so much for the review! As I added test 0008's reason for why I think it fails I realized that the reason the test can sometimes fail is very different than test 0009 which is for get_fs_type(). You see get_fs_type() hammers kmod concurrent since we don't have an alias check and moprobe calling fs-xfs for instance does not catch that the module is already loaded so it delays the get_fs_type() call and so the __request_module() call, hogging up its kmod concurrent increment. For direct request_module() calls we don't have the alias issue, but since we don't check if a module is loaded prior to calling userspace (I now have a fix for this, reducing this latency does help) it means there are often times the chances we will pour in tons of requests without them getting processed and go over the concurrent limit. I've added a clutch into __request_module() then so instead of just failing we first check if we're at a threshold (say about 1/4 away from limit) and if so we let a few threads breath, until they are done. This fixes *both* test cases without much code changes, however as I've noted in other threads, this is not the only issue to address. Luis