From patchwork Thu Sep 16 13:35:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12499071 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, 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 6A87AC433F5 for ; Thu, 16 Sep 2021 13:35:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 001B96120F for ; Thu, 16 Sep 2021 13:35:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 001B96120F 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 9CF336B0071; Thu, 16 Sep 2021 09:35:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 957E2940007; Thu, 16 Sep 2021 09:35:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 784016B0073; Thu, 16 Sep 2021 09:35:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id 6AD656B0071 for ; Thu, 16 Sep 2021 09:35:54 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 244482BC3C for ; Thu, 16 Sep 2021 13:35:54 +0000 (UTC) X-FDA: 78593534628.03.010B29C Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf30.hostedemail.com (Postfix) with ESMTP id BD2C4E001990 for ; Thu, 16 Sep 2021 13:35:53 +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 18GDIZqb004537; Thu, 16 Sep 2021 13:35:50 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=KdGBjo/df6iKvlQHpfavgWbFwB3X33QHA+9PgqVHcfTMMlc8F/5Lwu0FYcGXx0R2N40e 9pIj/ox4yz4+Bf8T0XehDRJrc5Cy9cJFurdQ9pWjJEDw7kjvv1VLIroaHoxGnXtXubHk ZvWqCERajsSzn+aOYx8eS3vUQuo4WB7SmEtMYMpMAEV5/sbtoBS5uaeepW1m85TzXZ5O V+Q9C4A3lpJobEL+N1z0oCnbN0mvJYG3AgKaXtTdue58pT8ixNaBVZnsr/sQppcBb2rP 1XRBmGjt6BblRABJ2M2EIX08Cb2Wqes5MhOX07DdAIT4IoY4etNtHH3UdgWlrISh9CCM Mw== 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=pAJ0kRclGanaph+hjJNgQ3RFSwTw1KAI/BaW8Tci06zB4wWNt/tiNJpGGF3Rk5qVyAf1 /qVBEMFFTzjTkjaaBMH4LvzIDzmMV7c5smVvG6k2K8qpUcM5wySBoRGnNkOCwXvR6UN3 4ea20BlODljQMBEd7s6+/YJ9gm09Hpj8qQXGirTiVYhzJFswXbm4nyt4Uc2qA7tn2752 aVMi5Ai7cHLe0wzk5J4nqDK7fvAdtpm2iJUEwb6TNIucoDYNFtdEqzoatflJX94XohKq +1HD8Q9CTxFgyuHJNXFrKYhR1VTizJUYCXrrPs7PrDewcDBLjvQFG71wHgYpLHXTTwQW Mw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3b3jy7kfxa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 13:35:49 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18GDUWSw156927; Thu, 16 Sep 2021 13:35:48 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2049.outbound.protection.outlook.com [104.47.56.49]) by aserp3020.oracle.com with ESMTP id 3b0m99bqm5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 13:35:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WtpRQ8vc1fota2Z71AIchlRVWWjaygYG2DVxU5kTz+2Af4WcZmTkFDWWfdRbhbweof74VjV7S9WJbFZIflnloYh708qIBXHq2DN5OvFuNqo2kVw85u6PCXbBzQVFKObB7bMdLX/RMlScPO1i3ZV6qKnFt3fSI6CXXvYIpsnSa7XtcENf/cH7KdW+JlGphgYHjuTd9w/Y9IfVV8QoebVpQhS9fZg0zgeTezXRkcA8d1Pk/cE1B0Raq5XTkemC3sjXcdBUb/WEBm/Woj8LbfaGDRWa2mLCoKhIG9tcegQ6lbPm/mx3Fn4uDYus60jeW6kce6eyiFTnUzo7UckRzx7odQ== 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=OcjgsgBlRMW1mH/9jG0123NMhUwiwgjWXHXFvBVZ2G4ijXVDqu6jUtwGv/8vK6M+LyNSEAxnTmRsaAObJhvnM4HSrJ5RDD8BMUAAz08y2CR8kWd9rYr2GVyPwtjVNrZkv4fLjWyWq1MGVgh8tGzEKmSFBORKnCumLU5qVB68gIfnlGhVHyXPN8g/InGI5livzqwY15PIc2kQ2YjpLnSrMU61+kseRTeOZMab5B1xd6qfs2nCLx5+glWKGvrkj9hGKMHyW6hLO9ym4s0jkMkQCtNNRKlRvrPQ251lWXofnJ3/4hm/KBVrhXnUVbt8FlQjat3OEz/cjjEYAzhNwA5qcA== 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=z8NvJuJyA8yh2srUo4DqIvXk10lldHXdEfMJLv3At93Kfl76rZe6V6iWp84Mu2j6XDadIO8qZ1j9G0EtYtfpo+h4DLt2FXn6ngOQSA6TDypUdC+EztQnrJZIbilOR738oKb3FwRk/KLwZC5S667xqO+ucibwyCc0bvnq6bXQ7Lw= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by CO6PR10MB5553.namprd10.prod.outlook.com (2603:10b6:303:140::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Thu, 16 Sep 2021 13:35:47 +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.4523.016; Thu, 16 Sep 2021 13:35:47 +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 v3 1/3] lib, stackdepot: check stackdepot handle before accessing slabs. Date: Thu, 16 Sep 2021 23:35:33 +1000 Message-Id: <20210916133535.3592491-2-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210916133535.3592491-1-imran.f.khan@oracle.com> References: <20210916133535.3592491-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SYBPR01CA0008.ausprd01.prod.outlook.com (2603:10c6:10::20) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 Received: from localhost.localdomain (110.33.47.182) by SYBPR01CA0008.ausprd01.prod.outlook.com (2603:10c6:10::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Thu, 16 Sep 2021 13:35:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ddff57d1-2431-4e74-12a6-08d97916e3c7 X-MS-TrafficTypeDiagnostic: CO6PR10MB5553: 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: 1hUPwRxppciOXfYl4OSnKZa1mSeI68GtAzNLbymWw+KJsq13vVxHjeM9prHms13Vw+xaHWFlaA01CGyntlJmeI5XOQ+Gs2K+YNfD7TocFoUQqCaD/Ga8elXtGHAg+HWMlH0vEAe7QJbZL7nCQF9AxeT9u3WFN3ZClL+HOMA19Qq2wg7qvfLK9vhwDMFB6TWFXIpwdC2LZSGpPlaDiNR7cJ66Fhvo2dA3ETsD4SNtse1xZYcE165kYRr3SnDuMN2BmAutNjBJGsvJnblM3Ym+HH+ZIaqm+4qCWqwEPtyW7p0Hbyub9t23e8T7HfYksTQUkx+eMw9d08KMTFluubKzigfMRLeLfk6gaipU7lV0dEwxMmb/mcZwxS4UCfE5h/scWUdLbJFe3sHoKi9w8oMPMO1RJMbMJPhwqoBW0k9eVEk0FUMfs/Hv+hpkHzKdvY1BZpYqs1YSTWgpD+dpb1YzQBGkUXlDy4JGvdtUCGSr6pzTNhAAAKPWdiaM7H/5qsxGmoN2hS5hcdBS6Ui1tkpKj+vsb9hoxG1I/Us/6jIkQe7/VwlyAW7XPf+xSvw5vqWbgMZQAik0aNR718CwJSqamksBMmMympUy2375Fye3xDEEeD42jNjhfLfOszWdLT5TEpnQONYeARfM5C8xMyzAf9ntLjO5uU5y7WXhFOICK4BABvnENAPyI76wsxgC93+3/7Wqf/g8Fp+i7tN408pc80odjcMwxS1tRvOi+fPzjK0= 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:(366004)(376002)(39860400002)(136003)(396003)(346002)(4326008)(316002)(36756003)(26005)(5660300002)(956004)(8936002)(7416002)(66946007)(52116002)(2616005)(38350700002)(6512007)(6666004)(38100700002)(66556008)(66476007)(103116003)(921005)(8676002)(86362001)(6486002)(478600001)(6506007)(2906002)(186003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wrdvudNLl22+ac2H6GB3SHXGypOMQD5FabrvuGTAosqJfrskdyccqIO+FVfcUBrgtYSWdZcAyO0s0SL6eQuNR0g+nG0ed/9vVTS3V0z5VGZ16YPidXC+Vo0aRR+FSR6uZH0tnm57MTPBl2tbBBHL2FKMtC7nCFDw+SbJyo85XVTl9IhI4N+xiGaSKIgQlG7I+b08aPjRZM1XK+hfll5aTNO3hJUS7PyPjXQEcwNNQd4xeOV7ujhGvvLDe2usJJn3dp2+tOh/HD9lSlTNsixTJP0lbxNxTAfnEt9UfrAoTiJzac8DZA36Z2T1ZyQeS01pWPriyyzo+flIkWHdT906I/lDI+EERwxSZlBeLcELWQ8TY5fvituC5o0k95myvM7fYNo8y+LBKypxR/COM/QEwo7H0x6tIzpaUE6JNUyz4TBqZAmQKCoP4F0wE68kjad62EsVigPxiJjFi6Uzkmc/ZY8izWshxHy+V3muWENAj2E1UBNKt4CkgArlgxRHr9IjcEtqfVZG5EVuw46ECXzbfDL846siWLKQW1RAA9aoF3uuI5cd4KQbynW32OXwg8WLYfwyYdaoRzK2kS7wQy3RYTkn82fjImvfH5Tk/TfzzPsd5gxC5XW1VrYoPi+FN0b4OnZ+GXwXP+b6FuZSCHBFVFjAoNHBGSMNvuoLCreb7KNfdkuCCDA94XpL/kQ3+f1vKolTLDAmyYcf3BoZuH8kgwVkiFHb+7JgEptWL7sOKb8ZMuBnJQiC+654QdcWWJTNXnjYVhKfWrmTHLorGB1AzqjGkiJO5ZzIKQdQovudq5Gl8K2BIzjYrPo4u4Wm87sN//0lBhLdKAv+lPN8qzSPtj9qVB8TiZ0kzR3AVZIKOtjfpmfpzw6O00d8CTNrExCEvwzwBYT4BUsddeNxTP2gVdMlL6ZSUizX7O4lyuY0u2rT4GRrGtakJkQywLuPcwRYYo61U9LUpLQHpZnsG77m328iedvF4eRZEXetgmBHnR4ePFgo0UEwbKpX/mJfua2CU1zjqutESLuedUzdO4ZYRF9q37qWMmaDYfaMfQXQcPJ6+qaLLFDMUZXtAk+Ffq9O8xi5Y67dZdn2u2vrGw9CX4bS/iteGYRZY0O+JVzvXG9jcqhJ0RYMfci2bdt1SAly3KuyuQuxhllc1s6b8VaDwoeqCfR42wUj5zMkFVLG9ngf+oUez+9yzsXMZlwiqm8LBterA7F/fDm+SIyDiLi7RQTsM46jVh+z8R+hKMdFbrUe5vCVAz4DTPgQgw+iRDLq3NdWbl63cZBZWDeSkwKdwbZH4/jdEZSDXjH95GxHjLPZWjguD14UZ8Y2ffOp9laW X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddff57d1-2431-4e74-12a6-08d97916e3c7 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 13:35:47.0557 (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: Vy0GT21oIPZsB50L47U3t0v1l7L4Gph8UC3KVmwW5nXjErstNHUxqdmroWVZ+WgfzV/EVOTHb0rDNYVa08FVDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5553 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10109 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109160086 X-Proofpoint-GUID: 3r-gevJr2KQdOdpNGk70154A6UhEbidF X-Proofpoint-ORIG-GUID: 3r-gevJr2KQdOdpNGk70154A6UhEbidF Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b="KdGBjo/d"; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=pAJ0kRcl; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=z8NvJuJy; spf=none (imf30.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; dmarc=pass (policy=none) header.from=oracle.com X-Stat-Signature: 9ryxmp4wkhooj8fsxhy935668e1fjc8u X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BD2C4E001990 X-HE-Tag: 1631799353-17747 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 Thu Sep 16 13:35:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12499073 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, 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 B09D7C433FE for ; Thu, 16 Sep 2021 13:36:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 41E7461241 for ; Thu, 16 Sep 2021 13:36:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 41E7461241 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 DEF82940008; Thu, 16 Sep 2021 09:36:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9CC6940007; Thu, 16 Sep 2021 09:36:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1681940008; Thu, 16 Sep 2021 09:36:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id B351F940007 for ; Thu, 16 Sep 2021 09:36:01 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 584882932E for ; Thu, 16 Sep 2021 13:36:01 +0000 (UTC) X-FDA: 78593534922.15.89E12F8 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf24.hostedemail.com (Postfix) with ESMTP id C94FEB0000AE for ; Thu, 16 Sep 2021 13:36:00 +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 18GDC7sd010930; Thu, 16 Sep 2021 13:35:56 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=cRRk+sXogVrt4bTvErjKswwrG1qLWtjGxrr6AKaZ/bge1sOzQi3buAFEXdgg1Ymw7Wxk 1bTJ9OB3vXYkdQVJ270JwzHpKHuOLY+dz6YtcbO3aoqIKp89186uHjwVC3zOsfyTZ/MD SXU/isMEd/3MLTz7eYLqv1q62G+aqBAFrsrNIvjgmUXJZwiI1A4hZwONNH5dRvbCcqh2 o/GEvW3S57pzla3+tmFz03DbE/SMSZxZqCPnAV0aWieDdcTUgmwOxYhkINXfzxiLiJ7t nlUs7EWYFbky7wWTM5flZxcL76TQoHmn+oQfMAPcFzBAC1HhXM8wOQrKmjCJjxGDkZUs 3Q== 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=PBIShyqfa39NTpEwTzd6S94mQtwYR6jG/Kxt8NIKGZ9wC6+b+XbLThNubgDpGztFR68h NtDOKNyElrmzptUl72UA5DO+gilxFtekmIDSAWPMjE6/fESvCsdsyaruzDzXT83knMCE N0in/7oTLbQjWniKEnLg15eXnMcsa1wesF5LEdg7HGXEPEM+CVq1VNeCW+nzytsa4OQA PBIf9ZLf0dOGX/9pN47zlaaziq0wICKa7QD1ienjw1hWCIW9zwQNUHgoysyqTeijeFgu hz5/qcK5HuFg5w6+t3ozmAhsJ661zNywbPssukF2fX5xstxmuw/c9OogFBYTwY9FJo4I mg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3b3jyskn1c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 13:35:55 +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 18GDUfa2023552; Thu, 16 Sep 2021 13:35:54 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by aserp3030.oracle.com with ESMTP id 3b0jgg51es-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 13:35:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kkKZUFi6wxJOxH5W/ksUDEFL5BUR04I3qL5dpWVTYfRjDWPSr3mbcgHEjfm9HDk7GK49KAhZPZIOY43jpjVkz98SF5+sMwLLHbgumB21FD5KUj+RvC8AyI4/I9rWSHFUda5b+O3R1R8XSs4neYI5n+I10VK7NzbC8t3Rd5p2pMlyD9AkKH5/9CvepXrtSaTZeUVeyDiX26dXUEwnMv4ehje69EMdQAOCL70BHisl2m3Ew7KYhJ/uYj65/FzTFGfd2jCnDEOoH2ndo6+pcxOyM5YyRM71nrhUnHyGkPFKAXYHh+Vuz+Vy+gQHzfrqGRWkqmYVLDlPl6sgW9iTttd+5w== 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=GJtU+V0VK4+KQUIQdjY1iidT0oKmbV09vDk8Q9Nfc5dk4VElQnCP7VvaxEyFz3X0bWQ7a89VAGcpRNBoE+LIgVrmNNQtU526AJ8Tu/jORwiA5N4rgvr1ml0n9k6+A8ZJSHTX64fM/3/o5OAaOWct6RPyrq+9eOvGxnWSoAUfriifaVyqo+RTY909jPOLKq+oTczDWyQSR3Y5MuYqRkRzp5I2w3ayei87tg0V/XqbozWGDdpzBhuumxietxy2vW2KkDJyy58tTS8e6cNeN674BNEXmLet1haGiNlq12mXCJPG/+1XyvkHu0rMyGR9FAtjw2hjVUFte6+/IGO+e3jIqw== 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=vi6R+eta9BDrwyNmrVWM0n9KQr0kBWdPq+mx0OxJY3T6/4FWMdDhNxIM3zxUlxdhIYrIg8RbjEcdRmY4BOX1OfwS1x8mUIkLPghGBPGlwuJKFjzKklfmCAqbiYypyF5epVtO7wahFNmUyy+c6glabdT7sbZ/CUB21g59wuuN8Z8= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by CO6PR10MB5572.namprd10.prod.outlook.com (2603:10b6:303:147::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Thu, 16 Sep 2021 13:35:51 +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.4523.016; Thu, 16 Sep 2021 13:35:51 +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 v3 2/3] lib, stackdepot: Add helper to print stack entries. Date: Thu, 16 Sep 2021 23:35:34 +1000 Message-Id: <20210916133535.3592491-3-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210916133535.3592491-1-imran.f.khan@oracle.com> References: <20210916133535.3592491-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SYBPR01CA0008.ausprd01.prod.outlook.com (2603:10c6:10::20) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 Received: from localhost.localdomain (110.33.47.182) by SYBPR01CA0008.ausprd01.prod.outlook.com (2603:10c6:10::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Thu, 16 Sep 2021 13:35:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76386376-b021-4bfe-9bce-08d97916e6a5 X-MS-TrafficTypeDiagnostic: CO6PR10MB5572: 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: V0MITbsavNlclSW5Cw0SpIzMO7cTH+lgrtr2eDrIMtM7T0Tj3GDPfW17eIppALHgwcX1OSCd61ZSFu8kT/xJJWNtRaGnMegffVrugRJlb2uVyBcnNd6bHgHgenbrgRvsdvGDVRjhZ+ZCzujZA5sN56oKpse7ZsVGOBO8zvZu870Cu6olpr7phItUb4COzasAdLC4Jq0nLqAjTyzaGnpyoIshVj89JtxICU5tw3aO6RCTUxnuEicL7a3AkXaPY5cTEchJ62qse17nU65V4NmmuvD1bi0PR2q5+df2KnRw4DbXtmUCyj+Kn5mbNPiDxbwq8H1Yff0Djg95pBCaYAWOLcP7w9QmejgQjebCT5nEtJLhfUKh0grP/c4409y7W2K4HjBeNowh48GKCn0e3PpJZ3Yt4xTimwmW0XGtL8ciX4mXSYfOMx4ouA2llAZ1jj7gccFEAtdeYYm7X8o5WeudUJrK4c9yLEFl8q4YnZTlBJMUrmlaVKOjIvj3AEDUDqfmxBfWaM4XwfHlGi2vgimdFlC3zWePrYqt74lfUBSTv7jn/Xkb5vm22x5PU7/y1sE0aefZsCQAeU27FscY+QExpCb7dpWXPkYOouzcJrB4K6VIVOZb2ycSszgJn0A9+5NRhArmhJhrCLfTdUSRn/+EJc+id12KvWDIzaioGDXMD2viVICxsqIUexliR3aZQnEMNVaofIH34RPFzdTqs2IueFr/FId8Oyqx99kmWI4//6k= 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:(39860400002)(136003)(376002)(396003)(366004)(346002)(956004)(26005)(38100700002)(36756003)(83380400001)(2616005)(8936002)(38350700002)(186003)(316002)(2906002)(8676002)(921005)(52116002)(6486002)(6666004)(7416002)(6512007)(6506007)(103116003)(4326008)(478600001)(66946007)(5660300002)(86362001)(66556008)(66476007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PtEAU187fu+/0W2gJFPJB68US1Q/mShYGjElkxD11pj4s50+SrAOqrZVS+R9xf60QkLFw72Tp6vBZlAMvd0SWeCHyvKsm0DFay4a2AwzKIyz6OREcoZtzSzGLikcnHIz/xXehi+6KXR0o3M24kZwvyDWFVCRXNOIBMcjmeH0W1huU333kPRvPBIkqVA6wSHuOZayVVkD2idz90TXyAaFYX4QpNwGY9hKU7znxZKf6g5wBB0cQI89qrOxUYSWwqiQ9oeGgBmLMHEO/68Nh/K9v79dtI7Wbmx/EAlBom9/jCpF5Ppl8dTCD4SHgSXULm/5XzHM/GQW9H/yrcedJW3cAZmi4YS9eRdoNK3M2vDaGKODoQ+H01ZVQ9lLwUKhVPsNJ6EerfomOQELQgpDMKEw5IqN+jeb972AvEuzsaVt1TGuTfMLIukKvKnxeIg5nT4nXVpyVg2Mhhaj5WjlykYkFnmEmjXUDSW+RG/MHxvcJNuY9LsQJHHieJSkCz6gLo4duQ5RBLSbfD2NRNxMyjzEq+G83AcOKyAHC1qn6BDWZeUb67NVacT4BQzZaHYCiV2NW2scQQA4h1O9jN4c+EYXJ8NAiyERD3602TSABK5QupLc+V1afhT0xi0jdW+otT5gVwCkUhxBj2IaaVBfeUhTooKxMK372/QZ7BkrwNt0um16f4UZth4kE0JdGbzj7ejpqT1N6G8oQl1q4mGeryCT6Y5GAkNsWbhb325vVl8gabhf9GU+FZCaT7qmHzF2NY9BoeqC8QnQuRhK3Ge30RmbFcLKGMV+fCmh5ioLa9j0ttbM/sCxl2gKQFP8rGS/WdPLHFZ+w5VlgmVm/YKD5zr1by1DComZyX6DUb2KDwxsCIci9ru8FuUgYePbDEFSh3sIxZsQSARdz3b66radLnvIj5clveLGyjCL+D9p5e/cWdUji42M/4W7x9SEi93ZabkyESZn5J38ckdPljVYYTbtS9VtmqXHtN8gmaB/mOENhZZPYpbLIZJNKRLWxIamGchnGNVLpgJUymBQBfgVRxB7nN6n3Ksl2WY5DUwRyO2yqrARhFlp7f+fZ9QWPEDm5plJoZxMXKz5NdEvzjXHX/MHnPfAy5++GxRPEtvRsChRN2vjm2uu7Lw0DR862I9Uq+VsrOaVmpDB4rDbZc0e4wVyu6+v9BsfTv5OLpGitKAw5j5/ry8fhfA7f2GYNbdP6WEZJIJRNcXHoVZePRg9EFVw65+FXdjEGJTlM2NvCMt3DpGrAgsaAyxvYOff39O6ZT6uKKdnJoxy3c6MXySAOY73FQ9ArviO04fGuZJKMBl3Mhd+ZzpnMFT22vyqxZ2rwUSi X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76386376-b021-4bfe-9bce-08d97916e6a5 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 13:35:51.6993 (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: I6XpVfrWld3wDGQZqLYlfp66viGkf0R6wcpfGzioFeW6rijcW9fDtNhXo0dnAEGM3YMZDjGbgQX0HvTIpb4xOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5572 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10109 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-2109160086 X-Proofpoint-GUID: 0aRCC4A6EcNd4V9Tz7sex4gGDkYD4kzC X-Proofpoint-ORIG-GUID: 0aRCC4A6EcNd4V9Tz7sex4gGDkYD4kzC X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C94FEB0000AE Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=cRRk+sXo; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=PBIShyqf; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=vi6R+eta; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf24.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-Stat-Signature: 91qzwuw8aurxchq6emr1ixtwppj9f483 X-HE-Tag: 1631799360-894073 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 Thu Sep 16 13:35:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12499075 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, 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 D5F52C433F5 for ; Thu, 16 Sep 2021 13:36:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7096B61244 for ; Thu, 16 Sep 2021 13:36:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7096B61244 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 0810D940009; Thu, 16 Sep 2021 09:36:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00A59940007; Thu, 16 Sep 2021 09:36:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7784940009; Thu, 16 Sep 2021 09:36:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id C5FCA940007 for ; Thu, 16 Sep 2021 09:36:03 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7C1D282499A8 for ; Thu, 16 Sep 2021 13:36:03 +0000 (UTC) X-FDA: 78593535006.14.9561371 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id 166B6300010C for ; Thu, 16 Sep 2021 13:36:02 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18GDCHpq012704; Thu, 16 Sep 2021 13:36:00 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=wx5WfZpBztikPSuUwtEhbSOsfuO0L5IaK5Z8T2MYYC0=; b=Z1NCjhAn05HCRc5PUeX+3xY79NnGUvcPQcWtpjGkHy7EbG38nLgY+JG1YEfyEESn6je4 GCLTu4smb3+RYPoJdkdk3y7WrbydxAm7Yga3vw+hrJwSj2ECT6mAbbX8W6crilmW2NWu WC5uKaia1qjo1gxzgw8itMjfqtd13s4hQDs29DGgW/tbkhiKxdXd7edH2R8wt6Lg7wN0 EJKWlH1Uj67bqPRHapopWUFPDYsslyJggbGLQgL2xg5BsJoQwrpB06g3GKYtTdPndT7y XZm7AkHO20+cRcfyGrWFTeIPB6JO0rxE8/mYA+02v1hijhv2Uk3Isg7E0TT25BZZqBtx dw== 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=wx5WfZpBztikPSuUwtEhbSOsfuO0L5IaK5Z8T2MYYC0=; b=j+UbCiJHQcAH0An/n/HAirlLRk3MoP7AMcV/tUEFhiRyfLwl+SA73nZTVmEC7G+jkyuA 8seDs4JHF2HZFL/RvHAWCWSxqe5WPbSzX2jhBmKYQOR8jSvPD5mAiSkkI3WNRLoLqgv/ BJSKp+XuDb0gA1AGXWR2FPAzW0fECv16WKqAxsBtA87Rq9khB+EWgK49DHDjVkUAFrzS zCZ1bCIGlytYS8WHyNfTdoCIg8zKrPPBhksC7tneOBYGKjfRgFPyaJqVM0iN5sNRXgYo B0owubN6v2K2uubXImRbKb0AU1IZzo0BOJ45W6pIxPc9o/qD3gk5J0Fj69AJgJIUTtS8 sw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3b3s74j9wj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 13:35:59 +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 18GDZK1M084032; Thu, 16 Sep 2021 13:35:58 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by userp3030.oracle.com with ESMTP id 3b0hjy8gk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Sep 2021 13:35:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IoFCokSP2MG2fQZcG4yK1Ji3pDIkMH3C0tPP7w8bXJSN+7n+ZJHFnK3Vcw6jmSvTAOpi3XOfo7KGkx0IbQ+MtURe+PSqfyJCDRAfjF5JLP3cK7dMdZ2yPsB8iWmKJfvx0O/oPKJIX+8wWDNIgeCWbxIPfnUDEItvb/R4k+KTMRBjMplYgXUznN3i8yyORIASDarfEnSoHzZepKhwNZgpCLCX6p2rYMkFsoVdIO9T4H6TaLSl3k8ZPRHKTMxqlCjzRObLzkI+FqewBlFRuoGX+nuO9ZyAZlCynuEkYxqrJ/AAAL2aBkELBAKHdQcqnoYtQOALgcsZQBGt0l5gHh6L6A== 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=wx5WfZpBztikPSuUwtEhbSOsfuO0L5IaK5Z8T2MYYC0=; b=NYcmaX3jeSHzfokIZyRuDIFgLxQG7pICEXJjIlv0L72ACSbWp8Pc/FQVZCyB7wtqU8ZqtJcVx9jlPVWQ/fwEMyf61HS8iQ7Qy1QBEHCxOJIfSBCfEqDh27eVWyzMfFZ+/G7xYenUiGvr+GqLpGW98GF2SpvYnxHKcVLnW374g6p28fB2Q8VA4SU99RrGB6/5B+d5jVSb5DMWVFt6n/aMoVMbTkagTsGCLYXjIeAb84tXdfmP95Vfx9Ugh4k3tERbllP4U0cJmv3GJsOBOkEu3gD8tAu+IzrBejDPa3T907PddOOKEXUC0idUJ3V0UpuVLqcv3bOMcKAdJ60mYWHmzw== 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=wx5WfZpBztikPSuUwtEhbSOsfuO0L5IaK5Z8T2MYYC0=; b=vMSulnLucVoQAHtr/nskOHitvGf04Ha/ua+4C1FkgpqHCxFkjdfxThU04Y6AY6XMpBLUEL4zSdwvm2BDqinQV27po5VZI6UKcUYQAfWs7c9a79sKKEFWiEAf0LMe/BEntvgstjJf9Hr3nRiSX1lP/N1yihqyl0LAF1id15T4EKI= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by CO6PR10MB5572.namprd10.prod.outlook.com (2603:10b6:303:147::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Thu, 16 Sep 2021 13:35:56 +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.4523.016; Thu, 16 Sep 2021 13:35:56 +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 v3 3/3] lib, stackdepot: Add helper to print stack entries into buffer. Date: Thu, 16 Sep 2021 23:35:35 +1000 Message-Id: <20210916133535.3592491-4-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210916133535.3592491-1-imran.f.khan@oracle.com> References: <20210916133535.3592491-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SYBPR01CA0008.ausprd01.prod.outlook.com (2603:10c6:10::20) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 Received: from localhost.localdomain (110.33.47.182) by SYBPR01CA0008.ausprd01.prod.outlook.com (2603:10c6:10::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16 via Frontend Transport; Thu, 16 Sep 2021 13:35:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3078b39e-e702-4bf0-41e3-08d97916e926 X-MS-TrafficTypeDiagnostic: CO6PR10MB5572: 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: RqbqLMlJ1H/keDqGbML3JnTmgdnePK/+IEqZIcwTTPu+MseEZwuo4NJf3EZYkEYIjnNcvRKSgfcaA7lnoqyew+1DkxQQA9k1iPZsQDQLUidhxE6bcBR8jCZzhmCFcfm5IKbZQK9OOV4TCa4BLNGTjU7vuFGjAciJpz65pTmV0J54IyN3T+eyTdFfqT+mnvAPuPkZKA1ugtE9OqbgdenoznM1urs06BJYc0WeJdXsAuAKyc+AIZhF0Uyxw5NXOXsaKO2wMGreH8gWFqEaf08S5iYApDNez9OJLaqzzN79Tx50Y3fuyC/naeSwnCqgIJRjdYuvXqNLqJsBOBt6l1yON9eNp+T3YVg0fQGaX4ODxw10R53dbwLLgWvCdlJV64qt12v+7FBEJhE3JueHwNpyWZ0zGxaT7ueAtWteGWckirsetBTCv1CRvZsCztlcff74oqAJ7TVH/KnLBxcDV1v7WhawUBvdj1AkIFwTxpgcUHo1zQ7WxkHq1PLl6ZQL7u7WNV5Ivm+fh2SzDQ9Fkh58ZRwXeqPofOMK2sljzvgkz9cRBAF/b9ltptsArIeF/9OcbOM6Dpb3Uo1KW5LxQuqoxI+szzMarGO1Wneo1uffn+dYQ3i5A01OyXCL89Aidf7drnCl+WP7orSKqmLiX2GuaoQLKSLrUTHXH1gJyThcAIAvrkf1uEZCegkdzHmu1GFigIZzEMuZU4/CKwCsjKaU2UhCLyp8bepMONBsrkbohwI= 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:(39860400002)(136003)(376002)(396003)(366004)(346002)(956004)(26005)(38100700002)(36756003)(83380400001)(2616005)(8936002)(38350700002)(186003)(316002)(2906002)(8676002)(921005)(52116002)(6486002)(6666004)(7416002)(6512007)(6506007)(103116003)(4326008)(478600001)(66946007)(5660300002)(86362001)(66556008)(66476007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: glgeouBfCvFvuzgKMz8698ZZ8dP3P/TdGVBri8zsdjHC9sDcyj8pRJmz253fSuuL7NUQuUyhtzw7C7QomZaWfT0ODar4JaPDbMM6XbLdk5+UT+j65z6GMewXkIDo7zBQVWvhzqMh5WMoWakFU47KD4mKmQ5fc/V6XB6OO2a0gGDmm1HaNUmLXvTK5z/vWTL8nXjqyM4hABVIbf/pU+oANx5fqB5AwBmkZRYjzMPUJNbFO2SAFZrki7PPUVtn3+t+hK7MJ2qps7VLmB0lHH58unk1gjbNxNg2P+YWJx9DV8OESIIik7sJDXTw+Rtg7/dlRPhPLMW7zKKIdkGBY+HQSYPU1wfjK0Y227v5xiF2ccbCCLLWsntvgdk7G2RdlQ4C4nPAqwnxwqOVPl1+DMPYBibcaN4qF9JCl8o5g3d1X4VB6jt/uy7O+GdlH5EQwtYgEdAMOBWaoR0AtAKzWZEANNwi+dundj1f6AjoHVOnbUIrDb6qS6PvUQLfuLGcy/Lsq8GBNSFVAAItVsX10SOGpEV2UllBwqCeqyUAhtvfmb2eZh4n56Lwq9/zIkGbKbfXi7f9OpVn9l6ZPkKUb/dU7OSVJe+UjHwYuOndLZU9gIw/+lsyY0J8sWD7K5FKYx/kKeyq6yxq4lEHrMFgYeqSK5Ee7uoC+nX8MMO1vjBl/SldbZNDvh5aMRpwFsnE6weOzJ237QQzVAD8O1yPa8zrw5O65hHHo/gjimGutPKy0erYno/u0KRNfgO6PO05ecP2CXKm9K2a1GUPtmDtD0d1ElXAi0Tr5rmuA5yLc98EKfPbTXyAmbvLnBkwmXCabpwdKzt9yY+Pu6ijKtzAr5ylWpyuLhNTujGNqne/cNOhuxna+DMN/gNPopcVvBTDJ2ykVTkkIncxvu7n23aaYCiqabUQk1Ks0MkLFscieuMBs7dFLSo6ehGnVAQq7WpQh1tqgPwFieg84APvvupqg+Wb04PTunMggPWE8J4ys0VSsaHDun50NndSGAL1Z48LecPKfh2u1rwEqfBQ9FXNaAn4r7slwR9FZsoQ1S8im2CgBnKz6JJOFCJL+bVJ7zXL+es+KxEQdbl654gRg/3HWRhGcCkIS9Wpb0KcUn8EsZVZYncOn2/Jch4mIacAu5A+lZgedVe56wgha0ue7O8+vUECIHl1iWWMrCSZpqBvSO+PJ1jcLU9JoTI5E3Fon4qkNEYqyNfyZm7B9BiRUQecm/RvyAtESMtEhPQGVHyAJfqluU42xyqSYupJ8+X98MaKWRmeyHmN8kHVVK24n2+qKvvoOJPVBI8Fjw1JrWHHlmLBKJcz02w8n4KnAyouGmEavhUh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3078b39e-e702-4bf0-41e3-08d97916e926 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 13:35:55.8620 (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: gGRTPMeViesqycXGR2SoGHNs6VU+Alc0YzU5wrHr7iSKUOhLNaI5G6rZalMIR/samrKCAG3nOFWby3crSni0ag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5572 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10109 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-2109160087 X-Proofpoint-ORIG-GUID: V132fvO_-FHOSG82cGI_Hrto9Gt2DnMp X-Proofpoint-GUID: V132fvO_-FHOSG82cGI_Hrto9Gt2DnMp X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 166B6300010C Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=Z1NCjhAn; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=j+UbCiJH; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=vMSulnLu; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf09.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-Stat-Signature: j9pr1irmih39rg7p14iayxp4ikxm5sdf X-HE-Tag: 1631799362-367028 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 | 25 +++++++++++++++++++++++++ mm/page_owner.c | 5 +---- 7 files changed, 37 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..7d1c578388d3 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, 0); 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..0d85f3c5c526 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_snprint(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..f953752aa885 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -214,6 +214,31 @@ 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; +} +EXPORT_SYMBOL_GPL(stack_depot_snprint); + /** * 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;