From patchwork Wed Mar 29 05:31:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13191901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D788C74A5B for ; Wed, 29 Mar 2023 05:32:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbjC2FcH (ORCPT ); Wed, 29 Mar 2023 01:32:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjC2FcE (ORCPT ); Wed, 29 Mar 2023 01:32:04 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAD333C20; Tue, 28 Mar 2023 22:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=KLOfytIcH4rEmrgbqWZrqXW6JlCkVbvgRIm3hytVuTY=; b=SKXkmQeCEpgQZFnKkN5jdqmQYh 40jq1pxRb3voL7778sBrMGEoSewmZSXoGUfZrB6wUK5nKoXSPw36MkaWBrYWszHlUIQqwXVVCUVCt IyMnqjGzt8GX8Pu2hFTRLiM0viFXqDvIkhHt5owme+jhbjQXGSDIqF7lbmtoaiS4lp5XhenvJfNrW ThblqC87znpBanq7PlA3vgqizKFHQmVFE+ZetKq2g+VimLRHoX9DXwbJdX8iXGmYqq7civwLsSvTc xgRc2rPq21dHnPvqDjXbbuIMsPnhrVCqtKXJOHk8DUupKVu2uwUCWdD8gQdFl8khfl+eycLmOdtcK Kfh2WKIA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1phOPW-00GgRQ-1m; Wed, 29 Mar 2023 05:31:50 +0000 From: Luis Chamberlain To: david@redhat.com, patches@lists.linux.dev, linux-modules@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pmladek@suse.com, petr.pavlu@suse.com, prarit@redhat.com, torvalds@linux-foundation.org, gregkh@linuxfoundation.org, rafael@kernel.org Cc: christophe.leroy@csgroup.eu, tglx@linutronix.de, peterz@infradead.org, song@kernel.org, rppt@kernel.org, willy@infradead.org, vbabka@suse.cz, mhocko@suse.com, dave.hansen@linux.intel.com, mcgrof@kernel.org Subject: [PATCH 0/7] module: avoid userspace pressure on unwanted allocations Date: Tue, 28 Mar 2023 22:31:42 -0700 Message-Id: <20230329053149.3976378-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Sender: Luis Chamberlain Precedence: bulk List-ID: This patch set addresses a fix to the vmap allocation presure issues which David Hildenbrand had reported last year in October. While at it, I've simplified the kmod concurrency delimiter using Linus' suggestion, and added debugfs stats to help us keep sane in doing analysis for memory pressure issues on the finit_module() side of things. That should *also* help do an empirical evaluation of module .text sizes *actually* present on systems, given userspace makes it a bit tricky to get that right. All this would not have been possible without stress-ng and Colin Ian King's help to getting a modules ops in shape so to reproduce a situation only reported so far on a system with over 400 CPUs. I *think* the degugfs stats *should* probably be used to help identify areas where we perhaps need *more work* to try to mitigate vmalloc() space, as in the worst case we can end up using vmap space 3 times for a single module, two just as big as the module, and if you are enabling compression one with the compressed module size. That's significant memory pressure on vmalloc() / vmap() space. If you'd like to give this a spin this is available on my branch based on modules-next 20230328-module-alloc-opts [2]. [0] https://lkml.kernel.org/r/20221013180518.217405-1-david@redhat.com [1] https://github.com/ColinIanKing/stress-ng [2] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=20230328-module-alloc-opts Luis Chamberlain (7): module: move finished_loading() module: extract patient module check into helper module: avoid allocation if module is already present and ready sempahore: add a helper for a concurrency limiter modules/kmod: replace implementation with a sempahore debugfs: add debugfs_create_atomic64_t for atomic64_t module: add debug stats to help identify memory pressure fs/debugfs/file.c | 36 +++++++ include/linux/debugfs.h | 2 + include/linux/semaphore.h | 3 + kernel/module/Kconfig | 32 ++++++ kernel/module/Makefile | 4 + kernel/module/debug.c | 16 +++ kernel/module/internal.h | 35 +++++++ kernel/module/kmod.c | 26 ++--- kernel/module/main.c | 164 ++++++++++++++++++++----------- kernel/module/stats.c | 200 ++++++++++++++++++++++++++++++++++++++ kernel/module/tracking.c | 7 +- 11 files changed, 445 insertions(+), 80 deletions(-) create mode 100644 kernel/module/debug.c create mode 100644 kernel/module/stats.c