From patchwork Mon Sep 10 11:13:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Tomlin X-Patchwork-Id: 10593935 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 2FFD9109C for ; Mon, 10 Sep 2018 11:14:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2044D28CF1 for ; Mon, 10 Sep 2018 11:14:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1408628CF4; Mon, 10 Sep 2018 11:14:05 +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 9229F28CF1 for ; Mon, 10 Sep 2018 11:14:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18C1C8E0002; Mon, 10 Sep 2018 07:14:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 13B3A8E0001; Mon, 10 Sep 2018 07:14:03 -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 0297F8E0002; Mon, 10 Sep 2018 07:14:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 9A1708E0001 for ; Mon, 10 Sep 2018 07:14:02 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id z77-v6so18925712wrb.20 for ; Mon, 10 Sep 2018 04:14:02 -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=EYAQdtxHzyQ1fOCC4d4SQvvWfhFo4NZ+BMXE6b0Dk0s=; b=JGyUuFhDJY2QX4jXZuKDWQtWdkJfZ8/6pDroI2Rkq8/bF3r3SQtfUg/eEHfFG2dCUG co1d+5bxVyySqiDSZ/V2kaP+PXo604Wx2zAUg3yGHA4HWj7VdkWnJ0XYvgQ0hQoU3D8W DD9eOkeNZywO/Czjts7+xQxF6yUNKBFXq46kZi9iWsZZ9Jj7Uap16FQNwMCLiaRr49wp PAm5ripKWZMM06rw9egCs2d4Rdoj+0nRUFPrSvgflNKjC9D40/4Fb5wDYJ1HHDZ2oB7c ud+eRdE7yzkylXACnKx1iDjCqSyv+OfFhf9QllJQ+zk/Uu5S6uuWzcr0dyH6vv5rw58d 2SWg== 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: APzg51CNfOvk0sw1Lo9Ba4QJT82BI1eJQFmH9hGZz95+m1uzXSmp37+3 0UKW6GeAVzFcUc1fqsKs0PpAQ7z5qXTHlky5jZsMJyz/aav0KEBYVYMqLt0r8I9Crvnc7s7Lb9j rgfe5OzfppbVeJGqVcFM7OB7E57xU5NRy3GP2KCRALduFDNbu5+UmGTRQ/uV0cjg3AH2JVIUf0r 6DZC0ogN7emrGC4swyJW0/HJRZiFjGpbGwRwX2S3Aa4mD/CqX+PxGHEmKVvSKq2OBhNlaphpJ1U Un9nAo7aqhNvOw0ZVe6f6W2+KC7K2gwoiMxg6qBZjMt5m4zvvXp/3x5rPxaNBY0QXCY6eY2FMvr nwPeKY3Qu2cz3jVNMDj8/TJ3Z5JJJTXdfIJcxfiYUkOcmtm6r2ED1o0uIGtZwlJYeTMygO+gbjs v X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr391486wmb.14.1536578041977; Mon, 10 Sep 2018 04:14:01 -0700 (PDT) X-Received: by 2002:a1c:5f82:: with SMTP id t124-v6mr391449wmb.14.1536578041015; Mon, 10 Sep 2018 04:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536578040; cv=none; d=google.com; s=arc-20160816; b=cKkMQKSvFRr3haDTfFxNpbJ2Ss6BlGI1D0qawQAEZs/0dL09kwBHecjl/QKaPN2Cb1 pYErAFvbt+45jo1SLEV4ZATrdtiD9BXVGDLWuHh/5B7zY9ZI9xZxF3uwCvD9xPcyZ8K6 xb/fn65dVuHSSYpbyqM+jRFdYQ9hnrF4c+nNNarUiNQCJxjg0W3gvePOb5ShCcnmmoqz G/d5u4LywzW9TtUtuFnlSQMP9mohCPfw0SLSiWQk0nHQ3CqDeLaxAdTIZG8aGNCRCHq6 XXEA6bcreJrIt7U982z57EbiLKbMh0nx7P82QnuFMLpygC3ZMYjP/H5fZfXONmoW9dJ3 PLQQ== 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=EYAQdtxHzyQ1fOCC4d4SQvvWfhFo4NZ+BMXE6b0Dk0s=; b=Iq99i1c7wKIWgbX/D8/2SObJ13NDHDSSdWBjfst7m4/6h49oKPtrfduUieKj8EaP1X oe0kLHvnVJ34FOxHnZgnF4ipwV/f8I4spMy0PdRX8LdSIBztvYPFpCBJIwBtIIs7EECf Ftg1mzGcLTHZ84jyOlyOmszYzE206Q53mj/gdhaeelXv08jCl0zlsWm2n9E1lus4h3dN BiFNHzhbFeak9hIdBqaay1XaxB9xyWwhtZ4lKj0vodjuK9KCxJWn82XLLn0o1INWOV/N N24StmRXkAhSJVXIuMM+29a6f1A3FaYE1VZsbr5ZdaF6a23+2XBnOGPj4eTHLrsipIqK SpAw== 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 j12-v6sor10113160wrt.26.2018.09.10.04.14.00 for (Google Transport Security); Mon, 10 Sep 2018 04:14:00 -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: ANB0VdbIDHlqGhafSFyBwUsu0SZs5tEyZbr0586+CAMr1DxvIkY+ezf9IJa00voIR6ZN9NguHdmk5A== X-Received: by 2002:adf:b456:: with SMTP id v22-v6mr13790478wrd.187.1536578040478; Mon, 10 Sep 2018 04:14:00 -0700 (PDT) Received: from localhost (cpc111743-lutn13-2-0-cust844.9-3.cable.virginm.net. [82.17.115.77]) by smtp.gmail.com with ESMTPSA id 142-v6sm14861071wme.35.2018.09.10.04.13.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 04:13:59 -0700 (PDT) From: Aaron Tomlin To: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, atomlin@redhat.com Subject: [PATCH] slub: extend slub debug to handle multiple slabs Date: Mon, 10 Sep 2018 12:13:58 +0100 Message-Id: <20180910111358.10539-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 --- 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..27281867cbe0 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, end - n); + + if (!strncmp(name, n, cmplen)) { + flags |= slub_debug; + break; + } + + if (!*end) + break; + n = end + 1; + } return flags; }