From patchwork Wed Sep 15 01:48:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12495291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9408DC433F5 for ; Wed, 15 Sep 2021 01:48:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3811461211 for ; Wed, 15 Sep 2021 01:48:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3811461211 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id CB42E900002; Tue, 14 Sep 2021 21:48:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C61C66B0073; Tue, 14 Sep 2021 21:48:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADB2F900002; Tue, 14 Sep 2021 21:48:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id 9BBCC6B0072 for ; Tue, 14 Sep 2021 21:48:27 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5DCBA3A7B4 for ; Wed, 15 Sep 2021 01:48:27 +0000 (UTC) X-FDA: 78588123054.09.161E4FB Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf13.hostedemail.com (Postfix) with ESMTP id CCBB3102D713 for ; Wed, 15 Sep 2021 01:48:26 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18EKxd85018637; Wed, 15 Sep 2021 01:48:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=djpiZ+Iw4TesK+uaQeTOjrZ8ApiLlTS279wKi/Fpmok=; b=0WYbvxcL1nXMXdPRZda/ZyvjEv2VdoJb171b9bFAmLCusfiTW3tOKsDdZc41wgWSERPj KVuggQ28rmbePwXJLdAYaU9w3sRqHgQUp8GALJz4cy/VbrA3S54y4Bwmt/xpfRDHp+qQ m28ZabiYowg87hrmySZCYhfwCXUu3zpoBKm2Ao1M/+aRKqc8A+yIjyYCLsuX4p8C115G mWSNBMYRHGXYFusX9tKO/QF/qdR1EIH2X7N7sGH7nBwnVmjR4+S6m0HYp6hsQ4ghgtPm bWxc3Qz97Reu2o7/ddE41VFKnWv3AqGuJIqe1bVHrBK1jfAEBNmMtOqAUYtGVhm2Linp eA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=djpiZ+Iw4TesK+uaQeTOjrZ8ApiLlTS279wKi/Fpmok=; b=rEMRty+pr7bOs7TMcIuAqqs4GMDTyjiZxWYvn0pk4sx2g6XGVPQAWFCHpGCw2+zVCaeu R2GzzOu8jpAbLkr4nO9GtT/8m7c1x7K7SzPzczbnG8OnB8BCKI4Py5qRV8b16baJCT/H kktW8XdjMbFfmh4PxhpNKb+SyX4D2zr04lIJY0HznViWOyIJ0lQJ/k1kVcbVIUjfzv3H 6Izn0ZHn+SzaEZBYoqO2/kePMst5EhAE2Vyv8GxHfbFie5CGNXAX0hlQT3h1XLAxi/7E DyplYWg91ytpyT2snB+YyhWwoZUJOE5HlsRyofRWYGKkFTdIz6GNVKHRE8LZ0pWE7HJO kw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3b2kj5uqw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 01:48:21 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18F1fD30052378; Wed, 15 Sep 2021 01:48:20 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by userp3030.oracle.com with ESMTP id 3b0hjvy76m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 01:48:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YNaBqUojL/VDMbqSjamac7gKEwB8WmM//uW90OIjhC5Ofxv+wT83SjAWnkWPXLawE/CE9GVh4loJcP9da2dLQxZLHU1OjmP/yp3kGOSksnM/npMBprmsVoUTTCg8aiOMZU6GuvVHWJL9qlVMhTYqq83MzgmAoZe/LCDw6c9AZKDLnm5Ofp3Cjd0+g55+PbfHneW9bhp2a/RogErqw1k1n7fK3PQEw5YnSn02bdaEPaLPYK3F3078i2V+JiDxfyrp+qrve1gvtHs1EhOdei3NIZD8Kw+VIH5JKz4twwj2mORAD5lf3KrPL7HlI2uO+WW+n7X86uuDJbnCqnfSpiqzhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=djpiZ+Iw4TesK+uaQeTOjrZ8ApiLlTS279wKi/Fpmok=; b=kth80nVzuzts7+H+N+u2xgqSL1SeaZQrVptIL2zc6z7UNGxX6FPiEr4B/sQr/18NOdVFenh8uZgcKKtCDBZtdqwfJAi27IheaOD2cuZK1wIxK084SDrY3lO/ZpsdE5jXBsnSqq+GUEjgRD79SH+DzIpcmZNIhhyonMgjtMCKs7YigIjG7epOJ6SbYbR3T0tBndLFjkEHBUlwneeP8FQLf4cOpFdW23Y6dRhU91DUt+cpeeo/DTsX5R/k21uAt7T/dEGsAVTaD+gf1fHT2aV1a47gnDqiBgW07YNbiFWKhxVYhON+m6/oXUkcipt8LqAwIgZYqILMPvLYCkDgc4mqbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=djpiZ+Iw4TesK+uaQeTOjrZ8ApiLlTS279wKi/Fpmok=; b=cPr866EibBQWKj5HU2cSczv+7PCjUHnKUA9HU3wg+v9CF2Cd4xcY1gPgJ7xvfgzXv4dG8+8hZAQrsVK1q5P/VcilTbdIkMoUAhR01VvhOeHcb18z/9JJ/aC5dooZAsS8wtbJ76f/i1GEZQKERkYm9qZd7rGjfzB1O8PBg9NGW5o= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by CO1PR10MB4577.namprd10.prod.outlook.com (2603:10b6:303:97::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 01:48:18 +0000 Received: from CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::f091:1dd2:38a8:e986]) by CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::f091:1dd2:38a8:e986%6]) with mapi id 15.20.4500.019; Wed, 15 Sep 2021 01:48:18 +0000 From: Imran Khan To: vbabka@suse.cz, geert@linux-m68k.org, akpm@linux-foundation.org, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org Subject: [PATCH RESEND 1/3] lib, stackdepot: check stackdepot handle before accessing slabs. Date: Wed, 15 Sep 2021 11:48:04 +1000 Message-Id: <20210915014806.3206938-2-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210915014806.3206938-1-imran.f.khan@oracle.com> References: <20210915014806.3206938-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SYAPR01CA0016.ausprd01.prod.outlook.com (2603:10c6:1::28) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 Received: from localhost.localdomain (110.33.47.182) by SYAPR01CA0016.ausprd01.prod.outlook.com (2603:10c6:1::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 01:48:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab695376-890f-4571-7ef2-08d977eae3c4 X-MS-TrafficTypeDiagnostic: CO1PR10MB4577: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: skUWA7aNH26xNnLi4/upUvdZsKq8mcqyRuXkG5xcV4EaWrYbE45yARJ1rYAoje/v3VgKN3gXxp2vntAsH42Sp2+tkdoJzSj1G0mtIYsd9YnhsUKfdlHLLSXP0NIj4h3oFxSUH83sjdx/2FjGCSVp4dsFCVMXI41tmqCHguYg3XN7zERpyKLjYDlaVi/XzdwLcjjpVkNIEdrIs+FqgikR89kn9y9azgRCI+7ZL8RMHIZbpJCfRS8ZlJMLzRAPB+hnDnmn7wCbQzu21MsZKGyMTjsY7Ei/K8k0mbAjaushsNAkVIUIjhG9OhksXXFYwmXQ1l+fTQo3pPfkDO9NNxLMBrEZeVesFxuy6UOxrG8h0WztaBTXQ5BLZyecmf1zpr2UDshRPmV6t/q72Af98baiXAknG1nAeujDnAwGbNh3mmP6eJHLrL3xbQMnoWmhPqTDnldD/Kx9Ybsi+8kxUtAosomwKr03JwepSfohqTqbji07/AiqrBtYU7jL9snN/7cq0eZMv3VnBZObeE5KTjPuvYHP7tG6JZpN45hbFQkHr6BmENJRP80OAeBr1HrDeDcPp1n7OU6vGWZ/0loXUwG78sBcCVBXX9HGKdgg9ti74ACxmdJ+nR+nAVvuGZC3q5igCNZXHqvxzUpKwCqwp2ksLb0vBIQUbjzKscfBSP3U+0ioXREJppNXIFReAzFafM8AJ9jvwhr4qK5s+fIvKkiAoiOlqq0xi4+1hIv4TgPqVvg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4468.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(396003)(376002)(39860400002)(136003)(366004)(103116003)(36756003)(478600001)(86362001)(956004)(4326008)(52116002)(5660300002)(6486002)(66946007)(2906002)(38350700002)(186003)(38100700002)(66556008)(26005)(66476007)(6506007)(6666004)(6512007)(316002)(8676002)(8936002)(1076003)(7416002)(2616005)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A1bPdLn+D0iT9oFWnEnYIGyU/lLmNaAr/56ll0nXp9tBj6YfhJN0JOqeodoBL/BaxwRxU6awo5XA2GNN4lVsE3SvxDHQ/0OFenzWbkzJJu2v0+A0ApubDD+l6Th5EKXf9tD6UmHVJ8UQz+uIEB6ScKr3x8mXa8UMv0ckowqmCiBraGFmK6eBojEH+Gnc682SbHieecBcVFe06/hV4s18/O8A7F3l/SICt0LfG4WY0Ak7HubINrifMHcNyXkZ643QMkCkmDarxupm4NvI130HU6KQEVxj3vC5T1fQ+3h5Z57ASyDOsG0gLMdXwmkeueUCOWHMFDHBh2J5fYWgdGmNUqjlSjRqQw9SOlzUDyBSLSHEbX6weDHEHA8ByUY7z1f352jsndd3yHt3mLYscPRgxkLU3X4V8PnQTOp9gsB9J4qyNZRoPs5NrkvlgRtMwAAYqCcSOwS5z6M9sqbv448Wca9AvMXjjSwhgKFJSHDks8lom8IZtZMb8tkxiVXRry9OqkWveRMWTkdGDbX5GtppqCczduSXgn7Q8Ydsbx5ipW1auduGpbuRcQXxA8KJdWjpZP4/Ac3xdegodY85OfdFUnFSHHab2ItY1/rV63V9VYfnO56smhfbvN1wHYVfhSsDC9P2AY5Eo4SZGBcFrF3H2mheHnr/0CIzth0K5h5Biy+WskAQi/sdzN5g6aVMYkIwh8sICmBWaur1ElXHAZElpoKr7r+pt20MaeJgRuYBN9OeEordYSQxIhasYjLLtFRGuMfg5gjBqRCrAiNjs64POCKE2dh4VdHCLgs+I7rMxQBNuXIeRyblrII+JvfaGXOswyReVHnxEGsbu6zyWsdSIRm7H7QPCDcO9vl3ZNP89WZfNsRlPVp2F/m/TYh6PlQpS8Xj4eGZYQDP04rCryW1pcaGEc1QnonB/denfSWrKXPNhBbWbRuKl7pC+g8sK+ku38Hey65MalHaDNkSIJuicJe225omqx68h7jqPuOOF2LNHCE9uy/7hUXwz15OVjJrFYZCfJsPyoFzevOGYruJdnlSmR66KhuXx8eJeS+k8bxUW30/uGWMVKIDOZI1Nn5APrHq0yiFX3Y4wy5Z0p0MwLbz0gGH8yx8bRBvRI02EU2O60Lk6a+Udwf17c9KvRmeDnziaiV1thKeXa0D9O7ccb5RKiFxfjtbxMTFAMA70abhI/ADcW4uQMsUpwsuV4cShxeToWNyeF5TVfjsIZEzy0E8AdMk10HKggIQRoIBs/aubIBTdlSTK2YOR2PMwgKWppqShgyGmpqE4UCgDXyo674M5FL0K3buDiBWMpR4bIryKbgvNIajKODtLbZP6wg7 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab695376-890f-4571-7ef2-08d977eae3c4 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 01:48:18.0299 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FJc5RPVxjWnkugCi4qjIG4Gprb0X/JHywoZuH2po+P0m5L4vfeqOshk08yvlcySYLMNf3kJdtkPNc2K02Tg/hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4577 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10107 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109150008 X-Proofpoint-ORIG-GUID: njEqINB1AZsZzz96KfLP4lMeuopx5NwH X-Proofpoint-GUID: njEqINB1AZsZzz96KfLP4lMeuopx5NwH X-Stat-Signature: ck9onmsohgsrz88qmzgd5t7pw6xbhxd7 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=0WYbvxcL; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=rEMRty+p; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=cPr866Ei; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf13.hostedemail.com: domain of imran.f.khan@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=imran.f.khan@oracle.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CCBB3102D713 X-HE-Tag: 1631670506-963 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: stack_depot_save allocates slabs that will be used for storing objects in future.If this slab allocation fails we may get to a situation where space allocation for a new stack_record fails, causing stack_depot_save to return 0 as handle. If user of this handle ends up invoking stack_depot_fetch with this handle value, current implementation of stack_depot_fetch will end up using slab from wrong index. To avoid this check handle value at the beginning. Signed-off-by: Imran Khan Suggested-by: Vlastimil Babka Acked-by: Vlastimil Babka --- lib/stackdepot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 0a2e417f83cb..67439c082490 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -232,6 +232,9 @@ unsigned int stack_depot_fetch(depot_stack_handle_t handle, struct stack_record *stack; *entries = NULL; + if (!handle) + return 0; + if (parts.slabindex > depot_index) { WARN(1, "slab index %d out of bounds (%d) for stack id %08x\n", parts.slabindex, depot_index, handle); From patchwork Wed Sep 15 01:48:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12495293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F7B1C433F5 for ; Wed, 15 Sep 2021 01:48:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A526060FBF for ; Wed, 15 Sep 2021 01:48:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A526060FBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4C3B1940007; Tue, 14 Sep 2021 21:48:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 473436B0073; Tue, 14 Sep 2021 21:48:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EBEE6B0074; Tue, 14 Sep 2021 21:48:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0064.hostedemail.com [216.40.44.64]) by kanga.kvack.org (Postfix) with ESMTP id 1CD556B0072 for ; Tue, 14 Sep 2021 21:48:30 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CD38A8249980 for ; Wed, 15 Sep 2021 01:48:29 +0000 (UTC) X-FDA: 78588123138.20.9455FA5 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf10.hostedemail.com (Postfix) with ESMTP id 72B186001980 for ; Wed, 15 Sep 2021 01:48:29 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18EKxbhG026050; Wed, 15 Sep 2021 01:48:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=dipXClo1/UKYWeu/BfE3k5ffLLi+bpTaCkDFmK7oqGU=; b=0ZZY0p2vPSKRoyzuLWvKu2U/plQdPdZRUmTKOxSdHSLe3FoyaiuzDLDa0TcbGEm5kgAE fX0E7Hxbz8bcU5StGi1TdwY6QfKQ3/ctttiUjVEvhjP2OFDvP4L5rx4pzTlC+4ZqgqgN ExTvHneblst9g2o/2qnUBrrCVpXjO5gWFoKUB/biVukscvh4jbOFG11s5yHqtFnUq1mt 3EuukbqskkS4OuOWO7hLFCRbQz0Cre9LqzgbgN8kVCkkbIvMOZUp4XFYWgzPgK2cIa/D U9Czgn/eCLUBwmS3YTdgWcZosgccq8pAVJMhEcb2FMdKwZ+J+DJhH25OqBFGKlkAL4YJ DQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=dipXClo1/UKYWeu/BfE3k5ffLLi+bpTaCkDFmK7oqGU=; b=APGMlZST5qBsYKRO+SGzlDTKWMiXA3h1laa7XorkM9z592fZWKG4hNSAdLpnoQVNj+2f YVRInNNLH+jdXuSTtDCTkQNO91NpU4O5rmj2Sqd+S+aPvnXgMgl+wuJ10wLFRgbaRZ6B yVc7far3TsBebaS/+qLCmWEZOzpY20zK37brz1xTyQf5uKvMdPrP67vuKFfQis9GVLnk hv6NSS7Mcnb5ca2ZOLG/eIoupltpcmzUKICUX7sPIT8GadDV/m+snqeZ0x7P04S11/+H RuhJpO4T+TayzX/6xMl3Wyf3lz94LmTJaXdQbgmEb5yoJH4+IMwsOVAszZNF4ja1Tt2Y KQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3b2j4sbs4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 01:48:26 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18F1fWfB091944; Wed, 15 Sep 2021 01:48:25 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by userp3020.oracle.com with ESMTP id 3b167swfg7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 01:48:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BzD5wp40tlStcO851+8bIHyNIVS7zEi/tITs4QP7fWbLzCIW+XJOgZh1mOzFCmgtIWJj/fvkInW0XDLh+BbH6Eucg4XD0GCjPmRyG/rN8Kf76XQ1jOfftzfZll8QJjUUtG9/ze+SKJI6SvOU20IlAD5Wx6wiVnusjmv2CScvsRD9I2JeBU18spmV8sXDNuGp0E+sbwTxGu6XO4YLi8zH8ICCLhVpnpUejg9e+tNTR2rvT1qKVDntUlwxF0tn5Xm1BT1skTsgOJ0Hrf2lhzLSYEg/6ooA8wwqXKpcJc/x8tLSt7p1XQOZMls+ejXAS6Bw7Kp8kL+2yv5W6TIB1dsGdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=dipXClo1/UKYWeu/BfE3k5ffLLi+bpTaCkDFmK7oqGU=; b=VbsHBpzj0or54iDsqmmujIpi/0jBfAfbqgb1uRjd8tQE771bBmUwa76hI8ETITzeZz0rlO0zirJLEl/se0g0iF94ecj+t3WEoZ4Rkkl3+zJ+dU84SGAG7sP3wJEeqed3bQM7kJO1VqmblBaZLcWAh5j7mgu+kSM9pu8DghKFjTQ1sBecX+7exbN+YtDUDVEHVJ636SA9udg5IncskDLSvjAh/Ng0f7fuJtQs8cz9xf1wVJp6LZpjLrfLjljioJNohPl8qPf8z3xroTvKMMmrALORhGwWhZMGgynIub/1z0U7Ekjxhd8kte4jJmAfUntahnxqGfLVYO/QDzhqaRD0Pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dipXClo1/UKYWeu/BfE3k5ffLLi+bpTaCkDFmK7oqGU=; b=GwaKiAWngeN7fUBfh/gqTc2CmYRE/Kbl9KzxjvZdMrRD2biidkyb5MGeYu2Wsx+VJyViWYfaPuOOnKJhzhR4CThu50YB8305Iic3tc4M1bnWu6f0JQjiejD6yFv5nxz3WiRubaJYpRLPT0t6PXb7HMmYMLYMScWyQ9qmylC7t9w= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by CO1PR10MB4577.namprd10.prod.outlook.com (2603:10b6:303:97::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 01:48:22 +0000 Received: from CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::f091:1dd2:38a8:e986]) by CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::f091:1dd2:38a8:e986%6]) with mapi id 15.20.4500.019; Wed, 15 Sep 2021 01:48:22 +0000 From: Imran Khan To: vbabka@suse.cz, geert@linux-m68k.org, akpm@linux-foundation.org, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org Subject: [PATCH RESEND 2/3] lib, stackdepot: Add helper to print stack entries. Date: Wed, 15 Sep 2021 11:48:05 +1000 Message-Id: <20210915014806.3206938-3-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210915014806.3206938-1-imran.f.khan@oracle.com> References: <20210915014806.3206938-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SYAPR01CA0016.ausprd01.prod.outlook.com (2603:10c6:1::28) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 Received: from localhost.localdomain (110.33.47.182) by SYAPR01CA0016.ausprd01.prod.outlook.com (2603:10c6:1::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 01:48:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 25fd4beb-d08a-495b-6150-08d977eae693 X-MS-TrafficTypeDiagnostic: CO1PR10MB4577: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:147; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tayQhzbet4B5SveKAysc3+lQs1wvBlqjjr/+AUkPBd57GNIw7vhtG+de6U7Tbw0AiVCBWN2/ez1W0FhvkaMk2uRy9fKjc39jU1C9LekuhvGIwatL5LDE5EMnvgQRyh/IOE+M7s0NaFJH+uOlHtW9MJ1d69G1xzG+HNLujpQeXo9Q/RqxD0xkymvpd5JzOZWp51a9KoAqqwu+oM0ol5YTiVnIIBnc/Ut5FTmYJAxRCSHBUc8FzmQr1agRxzUfbcoyPsns8/0KweZ/UONGWLAMk6WvSquXQ7XHW2v1eemY7sXNSxJ9OwOtP8xCIKzPk3EO9Ih8bMnlYQnycOxCCn9/GaoVDhKa23phKFCTafgmsdNSecpy1DF2DfgCwWIMJb9o5I86Cis7HGVEJHYAHCFt+FtIyvVpMxQ4fuWi2MU/N0fJDXhIMdHWwbNl6M788IdzEcdXap85HBV0LBDJq9brpfmaG3j21NVSeqIkvkUzRZpQk3mbTfm5uEaOmPjtZHqzC+P+itpG9Df8dJ/0MPfXCZRfdHOojnEy/13oOqBvWdOTo/sJCdTXeWS9Kmai2RSP1ehZuYp6N625NnmEPsuhIT5Cb3O4Vs/ljyKIsqj1nuYvfZ9C7A1pE2EDidP0TQcJ2p6FY3ct+yIEsZ+Rtblv0KVwek4+0aJ3P6J26chkFWIXMUL/0G9gOhH9h056Kk4lkGZ+YSjBlcVMngrJB93ZjIbMtz3B5zz5qnlvHHn//RM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4468.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(396003)(376002)(39860400002)(136003)(366004)(103116003)(36756003)(478600001)(86362001)(956004)(4326008)(52116002)(5660300002)(6486002)(66946007)(2906002)(38350700002)(186003)(38100700002)(66556008)(26005)(66476007)(6506007)(6666004)(6512007)(316002)(8676002)(8936002)(1076003)(7416002)(83380400001)(2616005)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZbuR8++3DzWAtSZPwXRh95AXSrVxCpeF0FWyo5i2ywl0cJZEzlzDNUX5P4rifO+1iHtZrfGUwMUdFw53RApi6gZc/YXsMU9Xo2WD9k2dKIxXN0phQXUsov1UpmL+4YUhgTkj82iMUofiHVJeQh6i8KkwFmYbTucc5UyItNT8ls2DSQDiI+iIru14ZSnyHH9KnSO1Kcy3I4TN1h7U/P9thZ7u2G0GbSV7QJjxxt2roWQIfxs5AYiexKvxnzTJkUPtfbIzBqd3EuOi7U+QioBUhTib6EYUYuagGHdKHpcLExr1OvEbZlbOkJAOvBa+kYqQxS8fAO77OzecMEkM4TtG0bfEQsAhpWH87qzyYuuVMvXlYikDQ6zHG46q/7+Pq6galSeIaramvGCm4y7rlevzCTidFE++QIpwde3L3EliXs1xzhqIT7wZilJwDhrlC4k2YDS8st8DtC4C8cTwH8lEhsRcWRp4t/GHbfxXpMl+g3bjRV9PYnZ9XlwmpG+EpDilVFq/RMnMXQ7z71gyV3xH6oM/L9Hef72fRkksdZMCpgARTGCCtK6JdDzqcrO23oLtcDY6yKCD8Y1Bjdz6cwD1YncNXCaZ3OppbFr5H79u8aWmob+EvHFqT4p+pIenvsmYDXAKVDrT5eeLQMPuupMVbhMJemUwQ/l2An0B7MhSB7ew5ICoBCOj3SF8IxXrGwl8ZpXJq4upbY6pdSgx+YlCOuHAKwRjdCZ+f4bz22KGxxCMiduL6mfpYRt32irGypAVYfSTM7l+ag9R5H5KUrHqtl41kBLbpmwxWeIJHLJRJvOgcId3/Q+00MMPFUciHPDfHocPJjUoO8P2x8QnMGdsSK27qRG+kGcs/I/IVxum+79ndvVR2gQdMDbDMgqNvTY49beCIP7hwgpWE62dGQDgV1SlkAlQK+2UzUjpS3ECorkL9mTaWx5pYtzVUlbYyem7LrfkGh+b5COOvbDXuEcEjO0hvpdWjaP+CYgJJ8ZPTPV/10HwrxP95wOcqo4Gghlq31wKh/LS/dlkIkYZPBhteMltCRYstUwkWwv6xC4+eN2lEcm0O9hVJigMy9+3xa5lXrqFAvMQmPQz5sfYUbtcz7Yg5HxSI11rD13lbn4Fg0+auF+LRGMlW+r3Qi5MRd0BFsDt1gsX6wlywSOhftb7KQkmnoJwlVo6viTkZbtx8b2ItSflLCAluRim8YdSk+fFNEgds2+eASIbjeySswBi9ohHqGMsDO5PGKAAA1h5aZaRixxtVj1CUNVjIh3B5gdDs9AMsssp2nHf4PVw67CXsLAstg73RuauDfx4RCpeooI+4+yKHZf263PpEv3XvT5D X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25fd4beb-d08a-495b-6150-08d977eae693 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 01:48:22.5908 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: J/8JFKW2LPg7rfGKEMfYIqQooIJiBF4nvJ/T0XJCJFGGGr4FiABbbNO7I25tJ+L9RQBcxN7o1yozfsapK0B/Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4577 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10107 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109150008 X-Proofpoint-ORIG-GUID: 6Zj1zZONZy-82WMXeALUx-Mi4dJ5FG8- X-Proofpoint-GUID: 6Zj1zZONZy-82WMXeALUx-Mi4dJ5FG8- X-Stat-Signature: xu3y7hb8arsksbwi8jsd7exf5okjopqj Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=0ZZY0p2v; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=APGMlZST; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GwaKiAWn; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf10.hostedemail.com: domain of imran.f.khan@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=imran.f.khan@oracle.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 72B186001980 X-HE-Tag: 1631670509-462921 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: To print a stack entries, users of stackdepot, first use stack_depot_fetch to get a list of stack entries and then use stack_trace_print to print this list. Provide a helper in stackdepot to print stack entries based on stackdepot handle. Also change above mentioned users to use this helper. Signed-off-by: Imran Khan Suggested-by: Vlastimil Babka Acked-by: Vlastimil Babka Reviewed-by: Alexander Potapenko --- include/linux/stackdepot.h | 2 ++ lib/stackdepot.c | 18 ++++++++++++++++++ mm/kasan/report.c | 15 +++------------ mm/page_owner.c | 13 ++++--------- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index 6bb4bc1a5f54..d77a30543dd4 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -19,6 +19,8 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries); +void stack_depot_print(depot_stack_handle_t stack); + unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); #ifdef CONFIG_STACKDEPOT diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 67439c082490..354fe1b62017 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -214,6 +214,24 @@ static inline struct stack_record *find_stack(struct stack_record *bucket, return NULL; } +/** + * stack_depot_print - print stack entries from a depot + * + * @stack: Stack depot handle which was returned from + * stack_depot_save(). + * + */ +void stack_depot_print(depot_stack_handle_t stack) +{ + unsigned long *entries; + unsigned int nr_entries; + + nr_entries = stack_depot_fetch(stack, &entries); + if (nr_entries > 0) + stack_trace_print(entries, nr_entries, 0); +} +EXPORT_SYMBOL_GPL(stack_depot_print); + /** * stack_depot_fetch - Fetch stack entries from a depot * diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 884a950c7026..3239fd8f8747 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -132,20 +132,11 @@ static void end_report(unsigned long *flags, unsigned long addr) kasan_enable_current(); } -static void print_stack(depot_stack_handle_t stack) -{ - unsigned long *entries; - unsigned int nr_entries; - - nr_entries = stack_depot_fetch(stack, &entries); - stack_trace_print(entries, nr_entries, 0); -} - static void print_track(struct kasan_track *track, const char *prefix) { pr_err("%s by task %u:\n", prefix, track->pid); if (track->stack) { - print_stack(track->stack); + stack_depot_print(track->stack); } else { pr_err("(stack is not available)\n"); } @@ -214,12 +205,12 @@ static void describe_object_stacks(struct kmem_cache *cache, void *object, return; if (alloc_meta->aux_stack[0]) { pr_err("Last potentially related work creation:\n"); - print_stack(alloc_meta->aux_stack[0]); + stack_depot_print(alloc_meta->aux_stack[0]); pr_err("\n"); } if (alloc_meta->aux_stack[1]) { pr_err("Second to last potentially related work creation:\n"); - print_stack(alloc_meta->aux_stack[1]); + stack_depot_print(alloc_meta->aux_stack[1]); pr_err("\n"); } #endif diff --git a/mm/page_owner.c b/mm/page_owner.c index d24ed221357c..7918770c2b2b 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -394,8 +394,6 @@ void __dump_page_owner(const struct page *page) struct page_ext *page_ext = lookup_page_ext(page); struct page_owner *page_owner; depot_stack_handle_t handle; - unsigned long *entries; - unsigned int nr_entries; gfp_t gfp_mask; int mt; @@ -423,20 +421,17 @@ void __dump_page_owner(const struct page *page) page_owner->pid, page_owner->ts_nsec, page_owner->free_ts_nsec); handle = READ_ONCE(page_owner->handle); - if (!handle) { + if (!handle) pr_alert("page_owner allocation stack trace missing\n"); - } else { - nr_entries = stack_depot_fetch(handle, &entries); - stack_trace_print(entries, nr_entries, 0); - } + else + stack_depot_print(handle); handle = READ_ONCE(page_owner->free_handle); if (!handle) { pr_alert("page_owner free stack trace missing\n"); } else { - nr_entries = stack_depot_fetch(handle, &entries); pr_alert("page last free stack trace:\n"); - stack_trace_print(entries, nr_entries, 0); + stack_depot_print(handle); } if (page_owner->last_migrate_reason != -1) From patchwork Wed Sep 15 01:48:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12495295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B38EC433EF for ; Wed, 15 Sep 2021 01:48:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 859A261242 for ; Wed, 15 Sep 2021 01:48:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 859A261242 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2C689940008; Tue, 14 Sep 2021 21:48:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 279136B0073; Tue, 14 Sep 2021 21:48:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F0A3940008; Tue, 14 Sep 2021 21:48:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id EF8AF6B0072 for ; Tue, 14 Sep 2021 21:48:35 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AD4B432626 for ; Wed, 15 Sep 2021 01:48:35 +0000 (UTC) X-FDA: 78588123390.36.E8694A8 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf09.hostedemail.com (Postfix) with ESMTP id 360D43000100 for ; Wed, 15 Sep 2021 01:48:34 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18EL03ZZ011618; Wed, 15 Sep 2021 01:48:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=Pa3eVO8EmjUg1TgHiwOuFRxKd1we5HRnv9MYKYeTm3E=; b=b9QMhFeAI8nF0WDMHMq+Tb8zJqeSXq+C98MA+sWZnOGTHfO4VMRTPgIbItWMMRpLLOyr J2R8UNSrwak3kV78InKJVlnXlWbaWUL9LzWj5ZxX71CUK40D6S1es2BlcSsoC+a+z8hs /DUQEpxaQ/LJLdQNtl8q4StSTZrgicnAUieKzjWA5mx8oj1v9yDLvwm5epaVgguNkjDf xRmRUbHesggPFqzrRuldhyQSzNdyLqt1deopsXNslEI8isCXbyHEwbPUz2+qwOO7GI3o FKqTp4DlfisJ5LUYUmJ7L6jrfV1xoEmodQZGcs5VpPQBqYcvKiNHsxN19UQ+KR0B8JXf Rw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=Pa3eVO8EmjUg1TgHiwOuFRxKd1we5HRnv9MYKYeTm3E=; b=Xco2hKGFDertlfU9FXztvpFFZrlBqZTXnMCLuEyDJVpX3MV9y67qPMvbnQ2ZW7fQ4lvN KW4RqVk9lyneZKAz1aMcolGhQyC4yOEwtNhCib5c/XsnLti4+sUkRNySmdM0PfgyAD05 Plo/ScN3uBhra3R//15plsK5jZ58W+sjScUXDxotjWs6mKaYYNsP4/s3S79UrTsfSoU7 R7/9PA+7kaeyy9zZFKoAqH6VHgRhgQTt8wZoLe25PVEvf52Ry/uoxDlrvkoIqpBU04OL +Vfj/atpTG2gEwqS9p/mccaCKOtGQDqu9KNSxu+qoLxClU+fl63Afa9E382WSNGDmCjD tQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3b2pygb1xk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 01:48:30 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18F1eZSl138012; Wed, 15 Sep 2021 01:48:29 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by aserp3030.oracle.com with ESMTP id 3b0jgdwmr1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 01:48:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G+RppqQDOi2jCeRo6vhsmBW0UtGDqkPXGtwszCPZbYUhfRnnEFjw3nbWZa6hg3j8FN4GyBnX0EU3DAKpQu50jYygqmWiizVOEoZ67tGnC+bMOS88PNEBWUL72HSjvTvn87RnCHt+XPHLTETZT7bthXjTWycdQ6VMhswFVbf/478X+w0mj49Uk4IV/cwbywDKGsP1Ypv5zIogMgV9yJj8xUjlOTD9+uaeCfPem6kAyrM7hNGtITfVS61lVcV2AoaWGtMp+8ET19ioJrYqpUvO9yIRAKKAOWAgtmQeFhJIA1/DxEr7I3Ik8toNKENShyH9IltdHt12HoSdEE0jXTTe5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Pa3eVO8EmjUg1TgHiwOuFRxKd1we5HRnv9MYKYeTm3E=; b=m0HnoGAIK3591qypgJi2CuKsK3ahrMXb/7boGcyAtPO2RjnMtu3w37/VcoziaH1NfFMj+3jLg6r44rwMRWzPfAcjcs9mRdr5iqf4BDY6iXXLA+uecp+kmu2KbYfqx357cjw5lr+agqijwnQZoBkHogI+Q+m+RCMMkk+348CXd6TQTWEyb7QrI0wzoWVf0HmE9pnioXvtwZegeG2Wyc/j0AJcwqO6httAGC7L7RtCVDQrTZwLMZ6pn6Ux0NYWpLw/v9sr+ZdnTXcPpoNcCvGOzQrzcJ9JTMhyp7o20enoNf2BzgldXcAjuM730eRUaTWVLb2YZYYVE/ezP0IvCyYyKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pa3eVO8EmjUg1TgHiwOuFRxKd1we5HRnv9MYKYeTm3E=; b=wtbdyfX6LihWE9ofo0dLJ2dFmO2631xjYHK6zxXeAB2PkQoyLN4G+biyQGNZ01kZdNhxQbE4C/HAr1x5gpk1exGeJVbrxeGYJiHYWZnlkv+wxsnrRXRWmadu87RnElUmpCe4WqiTy647VrggFBHFny/i/7g9saXoUuCnJZmvdaY= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by CO1PR10MB4577.namprd10.prod.outlook.com (2603:10b6:303:97::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Wed, 15 Sep 2021 01:48:27 +0000 Received: from CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::f091:1dd2:38a8:e986]) by CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::f091:1dd2:38a8:e986%6]) with mapi id 15.20.4500.019; Wed, 15 Sep 2021 01:48:27 +0000 From: Imran Khan To: vbabka@suse.cz, geert@linux-m68k.org, akpm@linux-foundation.org, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org Subject: [PATCH RESEND 3/3] lib, stackdepot: Add helper to print stack entries into buffer. Date: Wed, 15 Sep 2021 11:48:06 +1000 Message-Id: <20210915014806.3206938-4-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210915014806.3206938-1-imran.f.khan@oracle.com> References: <20210915014806.3206938-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SYAPR01CA0016.ausprd01.prod.outlook.com (2603:10c6:1::28) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 Received: from localhost.localdomain (110.33.47.182) by SYAPR01CA0016.ausprd01.prod.outlook.com (2603:10c6:1::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 01:48:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 056df092-c7d3-4d0e-2d76-08d977eae914 X-MS-TrafficTypeDiagnostic: CO1PR10MB4577: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1079; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nS45bygikH55TCJuw5b+JyRog/iLq9b8/hGIZmGcYFvDQdYOQwk/lY19i/Eqd6zcO4xNWKXtp2xChgqcBkXqJvkYajsYEqTJrqxg2DQRMwpWwx+5UVRvv7+kjAHtQRcUU/xwUNe3SXyz6Bxv0dlUigYNpcXmI5rmJvcOKaZXQdcjueAGae1N8sxHuRTapnopyIW+HzkPUa/7EvZj0DPiu4+paoNyYk4qGGiFhVbiIH0H/W+SQgZIv+ewZUrWDxyxjLHQu2L94T+YXuHkMJ5n9JBBFRIeMsu5uoYhbKMsOWYaxgRzHhufxOnnQ+uYv8D3tscmO6gQFPQQXsLSZF3Mrhuap324K0QlXX8ABslJpRO4kcZ6uSDQczQTcv80kaLQgicTmzaNRoFP7e4uWZNB92xfhe6+qd2j8BEqcpC+4sqPfhLX4d1D54hu+X/G75JQm3pyhQ8PYytRMCUV2rFMJh69b32T5MOjDY3lwss1o/YW/TQzMWosYbCQMej+oo47MhaktNmKgaPJ+a5vtC185KQH5isaH4y/HTvPWdl71ve0pGQb4FEwfU+CR8XY9OY0I+vYUo06Gd60ky9+qHzzDZOdeS1Xv+BdGYxIhi+HuC0LRYYfVrZTlgJ8RRAsRLrssVpmjopCURcigC0PE0eDPrzFXjr6Y7xBhMoj8hEd5RI7GKAxgqJ5KE1vsBNqFZ6mNkaBvCgy1jjHMtrsKlz1Thci4hgrST3yL19yU6xPkFM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4468.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(396003)(376002)(39860400002)(136003)(366004)(103116003)(36756003)(478600001)(86362001)(956004)(4326008)(52116002)(5660300002)(6486002)(66946007)(2906002)(38350700002)(186003)(38100700002)(66556008)(26005)(66476007)(6506007)(6666004)(6512007)(316002)(8676002)(8936002)(1076003)(7416002)(83380400001)(2616005)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k7RiKFSyQaA8WocPwfNBn4M99RNRm301yxmnOzI9CtV8Iif9D3Fo+Lbl0n/gd4Exat99ja97f2uVUN4kuv1tG4i0A+xdyIzSQIe/DyMthN1WXSXt7kochwGa8aYfJYQpMUVZs4MPW8mbIrd1TfJJXbEQhlUKDSYYgYpH6Htn1LD9Lo2fcdK2zM5z84CejZQTLmaKBNjbXiSmHxS5QNtUfWBYjM19Hnvl8nZx62PIjOyew0euXJ2B36fBE4RoWuMXWLX9bhdNp3B8i+Y5BUksmndI/ELq6JUB41v0jaBe3AEuXwCg7EYv//Yd7hAHgyOAW4ziV/PrTq+CqHMPG+faQisw/6RktPj0ZfgP9+ciPTQbBtYkr4vq8c1ZhJ04QseWgA2PBKfpQPezjLsdTx3mRL8en7UEhZIyHXm+bEN8da5i0Y6e+CdWaZECisjFPXIkzWXDPcp3WmnBj1nIRm/Cj6uGgZn5gD9WeCUK5ZpI19AHzxrxPwwXGy3Hr2o+warpGHNnD7UYV8G1gWOk0xMIaQMcMS1hLWDVwvL8aYL0irvC+fZOyaGi/6FhNV8Ag5W0GO9P0qm4sSs24MOD/FtrcAVSyjpYyIgvMmyRorbbLXM+SNVpoOyFC16hlDmSokz1zeZ+RZTks89jobNNcAQ7fx9yhl6IdxTCB1YL9WvGnkfpWM24Hb2UTvSouwpJ/M3VGug80KVA1q7WJ9VH6fFzI1jqBP1vz7pq+ItT8lnOcsuY4WH+TmkWFUHXyRZbUk18LWOC+lk49gWqvAHey7W6NAOHPjM8W0c2NjmGKn3ldymAihlBvRzn4LPGRAkT/eVbQ2V3ydqmN+CsrCsfwQSSpkvZvXndCd9V7oX5aFkiwgcu5FTOPsJtSximbffClp4vrKYnaxG5W0UbQSoRv/TN8OM86fiKrjhPAhpIr6zcHElo+jQ1yinOm7HmN1DcGNmwPm0QPuepMnuefWyTo8XOj2ejy4DUFr0hfCavYp5bwrMgK1pQG9++67cZhXL3oAzkJ32sZa78hDev8QrjFUyloVs7nna+mRLJ4tI5MlZinaPtF4QAQ7KcHMVcMPDBFaVqj127pSmJ3bYMzJiMoRKiWsrsFcP34JUp15yFwNQBjVERlhdSygg0cQz4pZ/oEqlqiixSPF0O04mD5sE62ibDsS0U1Vu8MFIgrZSmwLgM2EWSYBjBCzR/5fhEEyrfSJJ5vFRueIoDtCA53ZRYstjlr4iQ0f+pl4gvYC9XXqoL1fjyfHCbUqCL5iCK3ft8J9zamKUyNxwakQ/9wGORFXnML3EpNPwTMCXzcs4u9Xw+tkzqQj9EMW4rhIV37qpL0PlD X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 056df092-c7d3-4d0e-2d76-08d977eae914 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 01:48:27.1896 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KPpU44yMGTo6mvoDklPyyy9AALlLsGNb58FSCSilW2H04VmUNOjEoCmrGTaKPn8gGsgsFWFe+p1Sq0N8x2hi4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4577 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10107 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109150008 X-Proofpoint-GUID: gKYRBf5Tr875t2dmjJBiYoEh_PwN657d X-Proofpoint-ORIG-GUID: gKYRBf5Tr875t2dmjJBiYoEh_PwN657d X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 360D43000100 X-Stat-Signature: aaiug5b63sthb7y9537rh5sfc48g9ymz Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=b9QMhFeA; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=Xco2hKGF; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=wtbdyfX6; spf=none (imf09.hostedemail.com: domain of imran.f.khan@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=imran.f.khan@oracle.com; dmarc=pass (policy=none) header.from=oracle.com X-HE-Tag: 1631670514-398178 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: To print stack entries into a buffer, users of stackdepot, first get a list of stack entries using stack_depot_fetch and then print this list into a buffer using stack_trace_snprint. Provide a helper in stackdepot for this purpose. Also change above mentioned users to use this helper. Signed-off-by: Imran Khan Suggested-by: Vlastimil Babka Acked-by: Vlastimil Babka --- drivers/gpu/drm/drm_dp_mst_topology.c | 5 +---- drivers/gpu/drm/drm_mm.c | 5 +---- drivers/gpu/drm/i915/i915_vma.c | 5 +---- drivers/gpu/drm/i915/intel_runtime_pm.c | 20 +++++--------------- include/linux/stackdepot.h | 3 +++ lib/stackdepot.c | 24 ++++++++++++++++++++++++ mm/page_owner.c | 5 +---- 7 files changed, 36 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 86d13d6bc463..2d1adab9e360 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -1668,13 +1668,10 @@ __dump_topology_ref_history(struct drm_dp_mst_topology_ref_history *history, for (i = 0; i < history->len; i++) { const struct drm_dp_mst_topology_ref_entry *entry = &history->entries[i]; - ulong *entries; - uint nr_entries; u64 ts_nsec = entry->ts_nsec; u32 rem_nsec = do_div(ts_nsec, 1000000000); - nr_entries = stack_depot_fetch(entry->backtrace, &entries); - stack_trace_snprint(buf, PAGE_SIZE, entries, nr_entries, 4); + stack_depot_snprint(entry->backtrace, buf, PAGE_SIZE, 4); drm_printf(&p, " %d %ss (last at %5llu.%06u):\n%s", entry->count, diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 93d48a6f04ab..ca04d7f6f7b5 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -118,8 +118,6 @@ static noinline void save_stack(struct drm_mm_node *node) static void show_leaks(struct drm_mm *mm) { struct drm_mm_node *node; - unsigned long *entries; - unsigned int nr_entries; char *buf; buf = kmalloc(BUFSZ, GFP_KERNEL); @@ -133,8 +131,7 @@ static void show_leaks(struct drm_mm *mm) continue; } - nr_entries = stack_depot_fetch(node->stack, &entries); - stack_trace_snprint(buf, BUFSZ, entries, nr_entries, 0); + stack_depot_snprint(node->stack, buf, BUFSZ); DRM_ERROR("node [%08llx + %08llx]: inserted at\n%s", node->start, node->size, buf); } diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c index 4b7fc4647e46..f2d9ed375109 100644 --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -56,8 +56,6 @@ void i915_vma_free(struct i915_vma *vma) static void vma_print_allocator(struct i915_vma *vma, const char *reason) { - unsigned long *entries; - unsigned int nr_entries; char buf[512]; if (!vma->node.stack) { @@ -66,8 +64,7 @@ static void vma_print_allocator(struct i915_vma *vma, const char *reason) return; } - nr_entries = stack_depot_fetch(vma->node.stack, &entries); - stack_trace_snprint(buf, sizeof(buf), entries, nr_entries, 0); + stack_depot_snprint(vma->node.stack, buf, sizeof(buf), 0); DRM_DEBUG_DRIVER("vma.node [%08llx + %08llx] %s: inserted at %s\n", vma->node.start, vma->node.size, reason, buf); } diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c index eaf7688f517d..cc312f0a05eb 100644 --- a/drivers/gpu/drm/i915/intel_runtime_pm.c +++ b/drivers/gpu/drm/i915/intel_runtime_pm.c @@ -65,16 +65,6 @@ static noinline depot_stack_handle_t __save_depot_stack(void) return stack_depot_save(entries, n, GFP_NOWAIT | __GFP_NOWARN); } -static void __print_depot_stack(depot_stack_handle_t stack, - char *buf, int sz, int indent) -{ - unsigned long *entries; - unsigned int nr_entries; - - nr_entries = stack_depot_fetch(stack, &entries); - stack_trace_snprint(buf, sz, entries, nr_entries, indent); -} - static void init_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm) { spin_lock_init(&rpm->debug.lock); @@ -146,12 +136,12 @@ static void untrack_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm, if (!buf) return; - __print_depot_stack(stack, buf, PAGE_SIZE, 2); + stack_depot_snprint(stack, buf, PAGE_SIZE, 2); DRM_DEBUG_DRIVER("wakeref %x from\n%s", stack, buf); stack = READ_ONCE(rpm->debug.last_release); if (stack) { - __print_depot_stack(stack, buf, PAGE_SIZE, 2); + stack_depot_snprint(stack, buf, PAGE_SIZE, 2); DRM_DEBUG_DRIVER("wakeref last released at\n%s", buf); } @@ -183,12 +173,12 @@ __print_intel_runtime_pm_wakeref(struct drm_printer *p, return; if (dbg->last_acquire) { - __print_depot_stack(dbg->last_acquire, buf, PAGE_SIZE, 2); + stack_depot_snprint(dbg->last_acquire, buf, PAGE_SIZE, 2); drm_printf(p, "Wakeref last acquired:\n%s", buf); } if (dbg->last_release) { - __print_depot_stack(dbg->last_release, buf, PAGE_SIZE, 2); + stack_depot_snprint(dbg->last_release, buf, PAGE_SIZE, 2); drm_printf(p, "Wakeref last released:\n%s", buf); } @@ -203,7 +193,7 @@ __print_intel_runtime_pm_wakeref(struct drm_printer *p, rep = 1; while (i + 1 < dbg->count && dbg->owners[i + 1] == stack) rep++, i++; - __print_depot_stack(stack, buf, PAGE_SIZE, 2); + stack_depot_print(stack, buf, PAGE_SIZE, 2); drm_printf(p, "Wakeref x%lu taken at:\n%s", rep, buf); } diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index d77a30543dd4..88b0b4cc9906 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -19,6 +19,9 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries, unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries); +int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size, + int spaces); + void stack_depot_print(depot_stack_handle_t stack); unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries); diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 354fe1b62017..caca95e6660e 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -214,6 +214,30 @@ static inline struct stack_record *find_stack(struct stack_record *bucket, return NULL; } +/** + * stack_depot_snprint - print stack entries from a depot into a buffer + * + * @handle: Stack depot handle which was returned from + * stack_depot_save(). + * @buf: Pointer to the print buffer + * + * @size: Size of the print buffer + * + * @spaces: Number of leading spaces to print + * + * Return: Number of bytes printed. + */ +int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size, + int spaces) +{ + unsigned long *entries; + unsigned int nr_entries; + + nr_entries = stack_depot_fetch(handle, &entries); + return nr_entries ? stack_trace_snprint(buf, size, entries, nr_entries, + spaces) : 0; +} + /** * stack_depot_print - print stack entries from a depot * diff --git a/mm/page_owner.c b/mm/page_owner.c index 7918770c2b2b..a83f546c06b5 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -329,8 +329,6 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, depot_stack_handle_t handle) { int ret, pageblock_mt, page_mt; - unsigned long *entries; - unsigned int nr_entries; char *kbuf; count = min_t(size_t, count, PAGE_SIZE); @@ -361,8 +359,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, if (ret >= count) goto err; - nr_entries = stack_depot_fetch(handle, &entries); - ret += stack_trace_snprint(kbuf + ret, count - ret, entries, nr_entries, 0); + ret += stack_depot_snprint(handle, kbuf + ret, count - ret, 0); if (ret >= count) goto err;