From patchwork Thu Sep 20 20:00:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Tomlin X-Patchwork-Id: 10608685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A4E114BD for ; Thu, 20 Sep 2018 20:00:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C2712E2E1 for ; Thu, 20 Sep 2018 20:00:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 605392E2E7; Thu, 20 Sep 2018 20:00:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E737A2E2E1 for ; Thu, 20 Sep 2018 20:00:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93B8C8E0002; Thu, 20 Sep 2018 16:00:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9118F8E0001; Thu, 20 Sep 2018 16:00:20 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DA008E0002; Thu, 20 Sep 2018 16:00:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 24B6F8E0001 for ; Thu, 20 Sep 2018 16:00:20 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id d17-v6so10457854wrr.14 for ; Thu, 20 Sep 2018 13:00:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=Oup3WLppHI0eOzNCo9VZSilX4reqkH4apDwoiJWA2Ak=; b=g9TKy79F91EyzzT8dNuv+SJy794zzSsRMx0lUHiaNcLU0t/XXcD9Fs34WzwcoscpSv PjEpfFX372gwJKTeCLpLjKUZHQsZ9iD2VI0D4VCn0hJ0uIiD07kE4JHfHUrc2hShBIFU E69kgG1eGGgLGxNz/SUF4rdl8m5K+xpHgY3eHTqSzV5O5yOoyck9sO+cfoRMtN6hxFeg STaruaKYIh4Jz4FBlMQbRhoBIIAHyuGyvgRK+sXIPuL782P2PQYHoxsT9miOB6OVvjLT U4YiIb7wKXSoBtqyagdbKHNZrHcbmU6E8RNg6/8nOrxUR3+3aobu2v1cqv366MorUzwM 8rHA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of atomlin@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=atomlin@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: ABuFfojvQQC8vWxl3o897ctutut9Leb3poTh0slxb0g6CNXV2IJMgXWf nH56hx0jflC/zeeF1Gp+J9FoDm5SKAHqgrF9ul10uL0dlxCRL1ltQT1Hbckkm1kPkSeWhVP4l4S K+923MPze5TZFg6vg8MHCjo2+F6QASdQsYOkwWzWk+gYDTB6r8jdnTCWyy8zW58Nw0R3Iv7JDFz DST0JxjuVVZ4mEk+4VX3TialccAK/NZPOpBsJZmQZlKwO6mrZQ/XHl7nP7H883/PP15F32BQGPk scc3NcXpS7n1RE4qjWvMKxzMyPlp67jaMCk6tqtBLQQsMfPFDUrBpsd6yI8cu4cmXIgrRSj8c2O LL1Fd3aWvl1IUjO09HOgYmQHLrq0GKBjx8rVktfudYn/I0ewnA+lSQ7yRSZvj4fEVZTf9DKrgME 8 X-Received: by 2002:a5d:5248:: with SMTP id p8-v6mr2873315wrv.198.1537473619575; Thu, 20 Sep 2018 13:00:19 -0700 (PDT) X-Received: by 2002:a5d:5248:: with SMTP id p8-v6mr2873260wrv.198.1537473618646; Thu, 20 Sep 2018 13:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537473618; cv=none; d=google.com; s=arc-20160816; b=iJttwT1oSRPvbeAxbYnb/rYe/ovLOWYmwtcGG+RbJ6T1Fc+n0MvwxVjaebrlWb3XXH 2NDs66IYFB1Fm5p5tc3E8zPfCmjnVUC1V2ZIAbaPZCS3y/5ji0zdtkc2TDXN/WC9Oicr MQpiXZ2OqIR3WOsx29TJVA5SmKXXsseRTxIpSaCzmCsqFh4aZyn7P1oYOMxuloZp7Hc6 GwNdQ8iThREnN+Mdqx2sqwvi1LwERc3PpPouufEBlNI0q6h2MCnfdGjSKVJnAVwYvtnr KoSSGngiXnsYpK2z5EQCg/s+o9w/SUX4oEln3rHbQusRKAOtZgz5BSXOZGFfBJeZG3uA yHyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=Oup3WLppHI0eOzNCo9VZSilX4reqkH4apDwoiJWA2Ak=; b=Od871j6H3aV69mgIsXsp+whGxaCCOC13QfnqyA3SDlIPsGoefm8wcQDgjp9wMZ0wU2 sF0fDrMVSRIwJWNVZsEmDnWf/MN6tprguLfkAE/UAhzMzJhzIjXSaAAGi7xq8uE+we03 wMsUC6zYrJ6JSwZkFG7TDaCWinFVs5XgOYZW+McdqZMTHRoDkX5En5FiGjpii9VRyZz/ p3B8MxnXcWaNlF8QiSQTRfWcpTT4GP7dB8NsfyCCaux2O91bDHVmZtBgJ1swfvfXVnNg l+mT/Rfo+U+XGjvMG1Kyx9JxMSig3JdsThIy5EuzkEjD6WSJtIkq79cprIJUn99nAxVm i5Ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of atomlin@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=atomlin@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 75-v6sor2468277wma.3.2018.09.20.13.00.18 for (Google Transport Security); Thu, 20 Sep 2018 13:00:18 -0700 (PDT) Received-SPF: pass (google.com: domain of atomlin@redhat.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of atomlin@redhat.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=atomlin@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Google-Smtp-Source: ANB0Vdal4uNfMSK2xBnn1P8botOOkiHSv3xQHGCUzT5EQyaPpfPYcUUjFNlvBhErDMrRte79592TpA== X-Received: by 2002:a1c:8f50:: with SMTP id r77-v6mr4304116wmd.44.1537473618107; Thu, 20 Sep 2018 13:00:18 -0700 (PDT) Received: from localhost ([83.240.27.185]) by smtp.gmail.com with ESMTPSA id k63-v6sm5804471wmd.46.2018.09.20.13.00.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 13:00:17 -0700 (PDT) From: Aaron Tomlin To: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, atomlin@redhat.com Subject: [PATCH v2] slub: extend slub debug to handle multiple slabs Date: Thu, 20 Sep 2018 21:00:16 +0100 Message-Id: <20180920200016.11003-1-atomlin@redhat.com> X-Mailer: git-send-email 2.14.4 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Extend the slub_debug syntax to "slub_debug=[,]*", where may contain an asterisk at the end. For example, the following would poison all kmalloc slabs: slub_debug=P,kmalloc* and the following would apply the default flags to all kmalloc and all block IO slabs: slub_debug=,bio*,kmalloc* Please note that a similar patch was posted by Iliyan Malchev some time ago but was never merged: https://marc.info/?l=linux-mm&m=131283905330474&w=2 Signed-off-by: Aaron Tomlin --- Changes from v1 [1]: - Add appropriate cast to address compiler warning [1]: https://lore.kernel.org/lkml/20180910111358.10539-1-atomlin@redhat.com/ --- Documentation/vm/slub.rst | 12 +++++++++--- mm/slub.c | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Documentation/vm/slub.rst b/Documentation/vm/slub.rst index 3a775fd64e2d..195928808bac 100644 --- a/Documentation/vm/slub.rst +++ b/Documentation/vm/slub.rst @@ -36,9 +36,10 @@ debugging is enabled. Format: slub_debug= Enable options for all slabs -slub_debug=, - Enable options only for select slabs +slub_debug=,,,... + Enable options only for select slabs (no spaces + after a comma) Possible debug options are:: @@ -62,7 +63,12 @@ Trying to find an issue in the dentry cache? Try:: slub_debug=,dentry -to only enable debugging on the dentry cache. +to only enable debugging on the dentry cache. You may use an asterisk at the +end of the slab name, in order to cover all slabs with the same prefix. For +example, here's how you can poison the dentry cache as well as all kmalloc +slabs: + + slub_debug=P,kmalloc-*,dentry Red zoning and tracking may realign the slab. We can just apply sanity checks to the dentry cache with:: diff --git a/mm/slub.c b/mm/slub.c index 8da34a8af53d..d20901514075 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1283,9 +1283,37 @@ slab_flags_t kmem_cache_flags(unsigned int object_size, /* * Enable debugging if selected on the kernel commandline. */ - if (slub_debug && (!slub_debug_slabs || (name && - !strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs))))) - flags |= slub_debug; + + char *end, *n, *glob; + int len = strlen(name); + + /* If slub_debug = 0, it folds into the if conditional. */ + if (!slub_debug_slabs) + return flags | slub_debug; + + n = slub_debug_slabs; + while (*n) { + int cmplen; + + end = strchr(n, ','); + if (!end) + end = n + strlen(n); + + glob = strnchr(n, end - n, '*'); + if (glob) + cmplen = glob - n; + else + cmplen = max(len, (int)(end - n)); + + if (!strncmp(name, n, cmplen)) { + flags |= slub_debug; + break; + } + + if (!*end) + break; + n = end + 1; + } return flags; }