From patchwork Wed Jan 24 23:53:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10183351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9D350601E8 for ; Wed, 24 Jan 2018 23:53:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BFFC28994 for ; Wed, 24 Jan 2018 23:53:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80B17289B0; Wed, 24 Jan 2018 23:53:29 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 208F828994 for ; Wed, 24 Jan 2018 23:53:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932293AbeAXXx2 (ORCPT ); Wed, 24 Jan 2018 18:53:28 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:59960 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932239AbeAXXx1 (ORCPT ); Wed, 24 Jan 2018 18:53:27 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w0ONqCCi196188; Wed, 24 Jan 2018 23:53:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=7rjmN7/PNJq8GVLLSPFmw1xXQ3KeQU03BCHgOQnd+Hg=; b=J3wQdTxh2tfX4WjY15dXyLEmLHlPpypB9w1reSA3u2IxOMgKas2uKKnNP6nsqxFDy/Gh Q1AsXYcS6Qpkq+JKwmZj2BT76LjctPOpCUWeXsUkX+Kao4jbq6y4mq0cPM1TUX226Ywk /1FuZxaIm6pJV/OucMW+O2TfWD+HBy5oYdni+BOpKahZyRCaWTAKYPHAN0TXsPUV5Zcz cBvCS+uEhsG7Iw6CXHI5lJX1/MAx2hD0/u8h0WKtjhDGdfgP2qatoVBkLvwNzkRRyn08 /zOCRagKTTjSQKOFeGMZfSpO1pyxkxCe5YHT3za6N9OSgQOEfww6mOVDCJszbCe7T8OC Kw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2fq3qyr3et-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Jan 2018 23:53:25 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w0ONrPgc011968 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 24 Jan 2018 23:53:25 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w0ONrO7F003241; Wed, 24 Jan 2018 23:53:25 GMT Received: from localhost (/10.159.137.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Jan 2018 15:53:24 -0800 Subject: [PATCH 1/5] common/rc: report kmemleak errors From: "Darrick J. Wong" To: eguan@redhat.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Wed, 24 Jan 2018 15:53:23 -0800 Message-ID: <151683800323.17051.11972737619843691666.stgit@magnolia> In-Reply-To: <151683799705.17051.9987269343206294671.stgit@magnolia> References: <151683799705.17051.9987269343206294671.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8784 signatures=668655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=739 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801240311 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong If kmemleak is enabled, scan and report memory leaks after every test. Signed-off-by: Darrick J. Wong --- check | 2 ++ common/rc | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/check b/check index 9868d22..b7b3d57 100755 --- a/check +++ b/check @@ -499,6 +499,7 @@ _check_filesystems() fi } +_init_kmemleak _prepare_test_list if $OPTIONS_HAVE_SECTIONS; then @@ -795,6 +796,7 @@ for section in $HOST_OPTIONS_SECTIONS; do n_try=`expr $n_try + 1` _check_filesystems _check_dmesg || err=true + _check_kmemleak || err=true fi fi diff --git a/common/rc b/common/rc index 880555c..0d0def7 100644 --- a/common/rc +++ b/common/rc @@ -3452,6 +3452,66 @@ _check_dmesg() fi } +# capture the kmemleak report +_capture_kmemleak() +{ + local _kern_knob="${DEBUGFS_MNT}/kmemleak" + local _leak_file="$1" + + # Tell the kernel to scan for memory leaks. Apparently the write + # returns before the scan is complete, so do it twice in the hopes + # that twice is enough to capture all the leaks. + echo "scan" > "${_kern_knob}" + cat "${_kern_knob}" > /dev/null + echo "scan" > "${_kern_knob}" + cat "${_kern_knob}" > "${_leak_file}.tmp" + if [ -s "${_leak_file}.tmp" ]; then + cat > "${_leak_file}" << ENDL +EXPERIMENTAL kmemleak reported some memory leaks! Due to the way kmemleak +works, the leak might be from an earlier test, or something totally unrelated. +ENDL + cat "${_leak_file}.tmp" >> "${_leak_file}" + rm -rf "${_leak_file}.tmp" + fi + echo "clear" > "${_kern_knob}" +} + +# set up kmemleak +_init_kmemleak() +{ + local _kern_knob="${DEBUGFS_MNT}/kmemleak" + + if [ ! -w "${_kern_knob}" ]; then + return 0 + fi + + # Disable the automatic scan so that we can control it completely, + # then dump all the leaks recorded so far. + echo "scan=off" > "${_kern_knob}" + _capture_kmemleak /dev/null +} + +# check kmemleak log +_check_kmemleak() +{ + local _kern_knob="${DEBUGFS_MNT}/kmemleak" + local _leak_file="${seqres}.kmemleak" + + if [ ! -w "${_kern_knob}" ]; then + return 0 + fi + + # Capture and report any leaks + _capture_kmemleak "${_leak_file}" + if [ -s "${_leak_file}" ]; then + _dump_err "_check_kmemleak: something found in kmemleak (see ${_leak_file})" + return 1 + else + rm -f "${_leak_file}" + return 0 + fi +} + # don't check dmesg log after test _disable_dmesg_check() {