From patchwork Wed Sep 15 17:53:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12497021 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 EC5B3C433EF for ; Wed, 15 Sep 2021 17:53:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D4B7611CA for ; Wed, 15 Sep 2021 17:53:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7D4B7611CA 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 1E6FD6B0072; Wed, 15 Sep 2021 13:53:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 195426B0073; Wed, 15 Sep 2021 13:53:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05D94900002; Wed, 15 Sep 2021 13:53:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id EBD0F6B0072 for ; Wed, 15 Sep 2021 13:53:42 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9CB8882499A8 for ; Wed, 15 Sep 2021 17:53:42 +0000 (UTC) X-FDA: 78590555484.18.8DBD43C Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 0FF9990000A2 for ; Wed, 15 Sep 2021 17:53:41 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18FGQVkA032050; Wed, 15 Sep 2021 17:53:37 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=zKfVn/Mqc1xE4x64XLRXmpSvVCJ62Twm1d236cJpZl9yPnf66sJN5O1h3sxSx5CrYynG 8lmXGungbTTMcSe9my5CjeksvNiRH+PTn/AFhLifnx8WHwSlYa9WeQ78EZV/MPgDBjz+ ZEOS0IZ7G2fHpCyptOo6FvfQ7xifFZcP9wa/2SKhEsX1g/zi2ZrOc+tHFcsCo3Aoilof 5q4MXdTXpuAHy6+XVrXJ4vcnVysiAX2kGUZurk8x56XwHf+3i6jxKj1yLBhfJ5UoFSFo 1k9AC8n2C5qkOVq081ilpW0JNuAlpb6zpsIOS/2Mzq+7NCS5dkKQjUOFGQJdrkD0EITj kQ== 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=a5XfrbiPavTh73+Y+eCYxpGJxgeyAneBzfbm0VoSukjpNtEyckOWA56PzHWWasrfZNKZ N4uD4H2fOHQNuJvq2j6XG+0YS/2DA85ANqD/JL5eYB0pKTGKEo74q8ff4v2C8dNFfkXY mIvXjzz96EnV4dHXw4CkqmyA8BEizxAl2l3XkA3VPZ+0lv399xBR5cxT50kxE8b7BZT6 kfh4QiyehHRLR3y9u+F7ynbcMe2p6Gi7ENcEMKC3Wr5VXwjH4menpM/kJG2LkEBWX5ZJ SyY90rILeVedQov5oo+RUo5E7dHg/vcRCOp1KqbwEIJlFYIEaDgGG96wHtBSi5+28kq+ lQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3b2p3mp3nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 17:53:37 +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 18FHkb8R011001; Wed, 15 Sep 2021 17:53:36 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by aserp3030.oracle.com with ESMTP id 3b0jgeywkk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 17:53:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kXTB79vBiWsMnI5lwanDOdzOLQ138GrKLjAT6ueT8DrLoZ1XJ3ZmF1N2rF3+paQQ+LxYqkf9bLzJle/X4pSTFmZn5IsTMcGFU8rYGYk5vlR/ycKWTLcCu2PlBpZxe7qXL3zFLRx6gbs7MMYpGtGJAvXgEPv2I6UB+9Fb5gg1vgaC+3DCWWLY+4fo52pe6t0QH81fUyhPh+H/kwx8u1FUEnbuzbFkQPuHDl9ij4H2y8Ut8xulhvfXeDeBxh63Hz1onNEo+o/ppjsvxt2nknwtpazrwdppwG39mYnpjx7f3RdSdBxhLoVJFe22Uhjz0ZvQi7jm295s6n2ziz5QqO9b8A== 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=f3UH+543Ve8LOpISL1CKTl/atkRXkIHoPLLLUgkwOsOQK0cEv14kw6o4RLLa1M/shX2h2Lxu0YkKIxJ4To8/0jb0R4/nST5nfo14ARayhuEwY/Hj72omBNlnYV6r0a+8A+6V7pZy8b0oImuh8pY7zHIV7i5y0rWd927gg+EdyPAGnfYMvKXO0AhwlwQWzDHrQKKPH59p8PB5IdP66w8qBw04v4h30FcIRs7hIf2Y2H/azlz8RZHwj2QxPkkJeoe9daLormBDmxzGABgQXGNFsdxkYrK0ojMrXRAcZHp/UtmANyP2pxFfBFEDIMc18o20sJDB7nWgLAIpvA4SpLKQPw== 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=d3ZUtT44ww5GbBBWPuPNZCleqrABnJfcRts8/xdfweJizuuzFAVS5Dx5iwzCbVgsHQd8w7tNexP9ZMfcDwW/hCDlljgFiS3bEB188g8AS0IN4RaNp7u/xoPEDcsp9REh1Cntj3rso1GIaMrCzISI+MpO8/uZ7Tb6/Rn0vddny70= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by MWHPR10MB1568.namprd10.prod.outlook.com (2603:10b6:300:26::20) 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 17:53:33 +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 17:53:33 +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 v2 1/3] lib, stackdepot: check stackdepot handle before accessing slabs. Date: Thu, 16 Sep 2021 03:53:19 +1000 Message-Id: <20210915175321.3472770-2-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210915175321.3472770-1-imran.f.khan@oracle.com> References: <20210915175321.3472770-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SY6PR01CA0105.ausprd01.prod.outlook.com (2603:10c6:10:111::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 SY6PR01CA0105.ausprd01.prod.outlook.com (2603:10c6:10:111::20) 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 17:53:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a069c18a-1825-4b5e-b4a7-08d97871bbbf X-MS-TrafficTypeDiagnostic: MWHPR10MB1568: 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: u3Lm5TQIlUVOZO2oecX7ouScxglXQmPxd68bP8BnIrxS8W+ksohXkLBwwCNuFMm/tlO+zm3gXbp0kqUNVSiNmJOCyC+Zzo3pYb9KfVTTVmFGvyjXT3RnKdaOUF9lu2SnZ5Pmp87jFzhjt103vADjqaW1EEMLfPVIfh1Bpu0wPscmgDhaXS6zh/MnWIdd1WPhYDrqvVdLdQ7F/MD0izMwhBPyI4bVXnM12v7xUew3jdCJoN4H+lZD0R36m+MdkGE6DtECdGJweXC06yIdMR9W4P56Q6Z47nxczab2a3dP6+KiShl2XgYi7GmjRRaRTSULdc2Zc+Ouu3xbYClVGQJsrlHG7rsplKn7yvJLg7RePFwuNiuV9QzRkeJ4OwCtKylREWVwNcq/gfNGVJ+5kLWO00vxh2bQPdvtCbVdkVfhbf5CdMf0YamtvOiQDNfpFGWji2DHWImEjTswjv5d3bW55+LvcIPweOm5uma45ACpGaOYTBBRT4cAixHvWiu93fDn9tzvqWapwEbRJlAc11Ds5IRwL2gqfPZr4tCgQXyMjBS7Pl4LkPT70S41EwFzA5/3wjOBuJrvhUnD8bJelV9NgD1QJnG2/FIpWL4JV6gVH4yRfLisV0Vd3FrRsvtiRKcBjKttDOMZhGD7DezMuXIROxxY5IpX2Ew7l4DaEajtAOpRQS6CKRUSi2grXjIeBAfCCb42ZiPj9Cv+W4uCt/sBUi5AfKbE9aizIYKb610I8Cg= 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:(376002)(136003)(39860400002)(396003)(366004)(346002)(6486002)(66556008)(66946007)(2906002)(6666004)(921005)(66476007)(38100700002)(8936002)(6506007)(38350700002)(7416002)(956004)(2616005)(8676002)(26005)(186003)(52116002)(103116003)(36756003)(316002)(86362001)(1076003)(5660300002)(478600001)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Trjx/dKqg0i7yvemaymtLmhGpKWMn8ohJQp91GR+HhOkJUp0FBTwJ3SGcQuXj2M8cjnzP/hyzxZSTLdFSCD7Z/9T9IhCz1sJvvSr29iUog3lLddVtdudkqigj65K8d3CdU2P+RNNpGR1Sf7sne515aSyAKYonG+DQU0ndw7m4PFklfGAdQCV+WQg3Km1k/jD9KDuYMtF3gxDM7l71dXJJ3FgCS5lqOunP1rOB8yFJRVXfruhZ4cwWdfRa4SX+gi6KZoi4G60U1loIVkARFROvMMIY8yaUdVjoH5kUuM8y3ThZ9aeTlZUzO2B4jps4jx7nIlxrOhOUewcbTuMxPDYKgXANgzfje4DoB/DvZcIIdbld22fmjeiO78Gj1Intcx8a9pqhjdWPdJroWh993k+zenE/uJQctim2rfX7jkxD6K3fMOCDhUjE5DdGkiHWiTW53URAHFe23qYveCnz/YLM2aNYGrJtIoUXOjwC7m2Pqi4AwBMpvP5FM9ZdRQ1Y17YesNPI/x9G8XKJTWcOEMqQumQgBeg4irwfBXlIS+nncpXDL/MYzHzTUxdbwJXqU491wq+ijOi56f7YbjUSPUXU+A9XT8ajuE51/0V1tFPAR/vRVtUBacWFbhnLt0gM1N005m4aM6eXP1HKrgp4obCL4/WtWPDP5daHZlRaTneci4azcmT2T2uUQ5Z61sMu+RyedseH2sPxPJUBmC8NMcfUhhpH78xN6BkAHzQrekzbZENN/fQgGaLXO++1FNMvi3cV1XygWdEwZfkFZU0p7WCM4zzVLH0XkDEI3R4t8Io/kUn+25NjeHj66drLRXkoMYmHRou98h74LNbeM25v+/K5qDYh3t3HMbuZPCtaJ9oUsMgSxrJWKwX8B7dok1sLpbM3D+Cot/jWJCD81KBSyYph4NH37uanLTkAqoEBWUl7V1X2vxC3QtvwyGel14GDW0b5ZEVCbvvcuoV5mo9TueMIVxQZwIQ+dkWOBIgWaom9RK0cR7nG4OD3QBAzvXcuRaV89a/vkcUls/4lwi6d2ztuWMe0FfbvrKVzbmEYIEOnCJlUEpoSZbiYbplVqivIM46V6HEV82uxPBGxUZ0jrwTevY4ceLmVeMtLB0dkMAgvGmv2Xj28YOCcVc9YLYYKDPz+lzZOr31UwLH9RXy4P6ZOTAUnK3zaVbVzLelGTREalasmh8NXp72OE/oJnc2OxoU0XviEKIPIRe2PMaMxYPULiA7EYh0ktXe44B8FiGy+IErsfOzGi9gSBzmE/8B9h++P6sGJm39kbrooQreqJtLrnzSzWwvlbTLSWLAvEVfxwVxp5J2I7IsloCaLqk1apFO X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a069c18a-1825-4b5e-b4a7-08d97871bbbf X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 17:53:32.9850 (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: +6R+y6355P3zst+4PNstQuQc3mXzVlBTEw9S5HxG8STyHm9exRZFjBebDxJ4Loj3fJGU91Puw/+VOYTlMs8GAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1568 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10108 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-2109150105 X-Proofpoint-GUID: 3bRBentITE57k1T5UTIDpPS-FFao9OqJ X-Proofpoint-ORIG-GUID: 3bRBentITE57k1T5UTIDpPS-FFao9OqJ X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0FF9990000A2 X-Stat-Signature: 4gbz8qfimed65bhg56jnf6mm5c8io3og Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b="zKfVn/Mq"; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=a5XfrbiP; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=d3ZUtT44; spf=none (imf28.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: 1631728421-838454 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 17:53:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12497023 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 73727C433F5 for ; Wed, 15 Sep 2021 17:53:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 14556610E9 for ; Wed, 15 Sep 2021 17:53:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 14556610E9 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 B0DC96B0073; Wed, 15 Sep 2021 13:53:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABD5F900002; Wed, 15 Sep 2021 13:53:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90F786B0075; Wed, 15 Sep 2021 13:53:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 83C446B0073 for ; Wed, 15 Sep 2021 13:53:49 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4788A3A7C8 for ; Wed, 15 Sep 2021 17:53:49 +0000 (UTC) X-FDA: 78590555778.31.7B00068 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf09.hostedemail.com (Postfix) with ESMTP id CCD163000100 for ; Wed, 15 Sep 2021 17:53:48 +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 18FGe1Bk008933; Wed, 15 Sep 2021 17:53:42 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=Y118mjc/otwgsCK4JV0Ne++zcG23rxtLXPp5cbsRI2wS5PuNh7Czh8Vr6rBX5hgv95Tj tsnOLB83WsTOGQp50hkAOuoJ6PrYB12za90bdbPGNoH5guF2UDqRGRV4MbweAMPsrxho o5/A1zX8ZjRRGLZcmR62KctH1bEanY1Z5U9+pf9Whwn0j76myurIq6bvMhtITQOi2VpI Kw+2p2Y8UvGzfUDox/XLHtpJj8AhTG2ZvLBx2dPYZ3k7cB1b6nSULwr0zTPgKbVp++Ww qQrXUDRwpkbGaJZlaVQ91hnynGwUp0yY5aO3mBQjpOlTdaT4jAQCc3GpsOlLPMF0gwGW kQ== 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=oYJqXSY7QmqnuJpm7lW1pBZiO7EtfwPzzihXXgpoo6TOBnapemsonv5JL8EMXgNVLSkK zRVSYy1cDLWCkKAwLl4RhSolfkwGpA/SAuWdGUB8DSBwOnKPyVrIWBaUTE6CJ+LseGER fIR9myW1zG1hxTUw7Mgelv+cpHfL5SmsYzdcBpTUrdT5jjwIOryBkj6BuCLHt9lm/Z9J cD+zyQ15ysChR7Ha/19h3FUBi7xDeiZei2w0+tCOaj5g4GZ2XL5sCwZ+eOh46YR81fx8 S0jREcADt2L03ha+u35Rb2kihCS70a+JQkQjCv+BQgYntub3dHhoHZTAO4UiBna42HTr rQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3b3jysgpyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 17:53:42 +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 18FHkb8T011001; Wed, 15 Sep 2021 17:53:39 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2040.outbound.protection.outlook.com [104.47.66.40]) by aserp3030.oracle.com with ESMTP id 3b0jgeywn2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 17:53:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ey0Ql64XX06krrkzdhuMo5oIQxw+TfefvqMt7pX93f1584qX5LLPqhIRO3Xv0JPHWawp3+apZBWlwGwZpT8NwJipbgIU36UFL+ATHhLRv1Y8Mofz6yKfbngF9A2yTaSj0vqj6eQWon2478Yq1r+TZ+no24XmjZvnXW1HWXD/4Smw2U6ZwlqfUytW04hT9AxNYDuXwjHgTievwX/vVA4Ljgf7pH/0MaXw6JYfneVIYtfw1M5lXa0amluoyzloGSixpHmQPY3kkWgoby1GOnk+MC3xF+oLLGOvnELL8IQJt324EvJCkJh7ONUVamMI9KaxlM1e98XsMnm2bfEj10JeFg== 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=GNR189uZeXkf2aqPJWhWxiprvCNHpfbAbiePiPcfFzLapS/SPyFUYZPXyfQKtetZdq+xA4jbfrWAR9Y0NFcLVFZnx1s1OOtwI8oHpCWp4cREu+rPSfLqQ1QCQLZTVZ5swnPBqI8WM29Q0wIkRm7MyVyKD0AqQ/Sl5HGK2iczVafmVO8u+5ER6/6N49FNjOixXIHDojnv+qx5nHi9lQgfVK5ZZVyMRvNEpEDOan3Qke7lf4ZmiciyzHACzP1eFnpDqJcVbyMQpyNYvWLX/5JFXAvk54KgIOcVVMNpAZ/ydXOpbTXg/l7aHwjBxaU1jIks+fH3XfluZEEx/EE+B0+yMQ== 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=l0fRAhAnU700uxYPTsF2GTxF1oC8WE2lvPQlXtCoVdMOouX7bQ3e2T9ayxEKQBwbsP3guOsa8T7f7WP14Nh4O15EnJQX2+AMge3iPZDNLxG3Vko/DJ559967t2LfeZLGEntC20vhkxiaxvZOVFfWvmEGafK9/Q565xYpPz5+518= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by MWHPR10MB1568.namprd10.prod.outlook.com (2603:10b6:300:26::20) 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 17:53:37 +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 17:53:37 +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 v2 2/3] lib, stackdepot: Add helper to print stack entries. Date: Thu, 16 Sep 2021 03:53:20 +1000 Message-Id: <20210915175321.3472770-3-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210915175321.3472770-1-imran.f.khan@oracle.com> References: <20210915175321.3472770-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SY6PR01CA0105.ausprd01.prod.outlook.com (2603:10c6:10:111::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 SY6PR01CA0105.ausprd01.prod.outlook.com (2603:10c6:10:111::20) 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 17:53:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 00ec7627-1dff-483c-7f6a-08d97871be5f X-MS-TrafficTypeDiagnostic: MWHPR10MB1568: 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: yv18ktMtu8YKm4nGfpioKOJdNUUC4PfbH6j5qLaH0FkI0Mf4CmXb+zACs+I6taSKfdhfZPoJNNM/hXZtYg/xvHaFk6Hf3d+Jtswe8qx5Q4q3iJSsLZzzQVJLKn9Z8sG69BiSkSXKL8EbTIOKIulw72HHTheuYQ+zGWjla+wMn7zEk2SghKqnilgowuMghlINikbj8M8iQ7iz/P3bIKxBrJUATj2nuHPU3X+HrCPVU/TXcpsXQPH3M7KLpnWXFLPwz+o/0sBU6UQm3wjJoPKXiVtub6DLWcDlWLnQYOSbrm/MIcFM+MMRGrQj9SSa1UxUBemcjszcBNJ3b6FsyBqeAXTQH64Y2Ge9gSGsJPzhzOj3OasTY6+fK3XL2PKtNsc+w/XV0A/NSgnpXqLqz4Bura1dgB7PJ2tVA4n3Uo57EWUgRf9XyckvHOLDjQJMcbpzQQJRTSKMFu9Aot9xRzOAsBtvO9xaH0o6lHFBIGEl3PAzuZAYnixNglFxoRk9jIXOldt0m8sOSlw54/dfVfr1+Xt16lMxFIMjl08OAtNxqOxnWefEDLbq6d4Z/NQI6tKf6+I8ZI9vZg7CNZuxLJ6hwlifFMeQ5enz8ZqOJRjEO7m0M0cUR8XlgPkieF941xdHO73uHQCHQ3mw1gPdYV/4gjQfdsOzWv1dpZHV2BnkiA5Ttv4Xh3Y4pzW27cHn3LXy71w+VlMPdY6gHFW/efXYh59eyYwuAxhBiMCythvB38c= 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:(376002)(136003)(39860400002)(396003)(366004)(346002)(6486002)(66556008)(66946007)(2906002)(6666004)(921005)(66476007)(38100700002)(8936002)(6506007)(38350700002)(83380400001)(7416002)(956004)(2616005)(8676002)(26005)(186003)(52116002)(103116003)(36756003)(316002)(86362001)(1076003)(5660300002)(478600001)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N/JrJ7PVGJYPqF9xroHqOLGoVrkHurGfkqXwIoDM433gQE8OWed1nbv+oirDzWPex3yjpi2sk2cAoSMglh+KP93efeZTm+QM8TCjodfWTA8qqn9NH8qSf1B74Ucb63jQY89hby3WifeIMrFID1mbaUwqviGxnDCx3wNr0lORWTANpomrT6Z6V5gncLZwmi+RrmzuWfCJnEpYPXsmqS3pqqToJo8NnY9BMKFjKQf1WHrbrtAix1iFXgbuwN/xjUO6W2mBDxb3LDe+nhB8NLHs79u+nnLhGaywMTR94oO1eeTptQsKu232iWYoE2Sk0jwMprb+rml/pK180zeZqLYTRlcM7WJERcbSk0SwYChGbFo6ClMwhST57kwdXuw8bjChVEkN+4n2M1CsPOEh9eECDFKXZQtEJjjweha/1f2eilcAkyrx5lC3QuvS+bIF2fhV9d1cY8DYHNxpGlodX+5E5n8ykJIat20iJKn/3hEWaNVevYXFAwNyqbZdA5SXoa+saxJuvC43i/OZ9VyySQJSBuR1etYD0wWIiObP4OX6XZVh8Iy1QB4ikWOKKGEVmVaUU6zXdywhZrPv8n/PCwBX30Ga2Iw5X6Q4/V2MnrNUbIMKtaVaq7xklenKCJNrnNRk3DNUVXcAmQGj+Dz/wB0k9EHPJIxaKD4hhLkyQFuaOO6nqRXxlW3Fc/va4XDSIVIFV7Mw1MiRCFfP3fdusEthrnBlMTTUg6+PrhFoEA9nY2WMpxyWhlVnUZ39YPUtrierLBG4arcXvd8hvBjHMSY+nwWnp/s3ubYEIrsjC8dyMvBcsojUyNVg16Y253muRfiF0CykmCDcPPSDPpDYmewUsVY9NPjuM9t4XxKi0WFfIl71shSsJivwpPCK9Pyvn7tz+Xq7rDT/Opt+1aptuhNmQsnbp9EYqLgFDaiD3KciwhX34pHaLTDIe7LQAC4DIyol+upoQ+1+pOJQokX+7eAu9FIoDcxyiWAvtZRCriWqWVS+ISlArCS55qZ8ZOYnzwpvGJfe/rMIxuCk4EyKBQc80BrTIyZw6RVsHBpEPo9XJ7Ef7x+qhfXVlWftKhgXBEH47vc9Bb6lu6yLVc7tSM7ZZ4Q5LsYSXJis8eDMaaPOEBHh51Y4FFyB0oBi0lvp9a8EdJ6Qx3T2MN1wTwpDks59xHOh/V1C/KIQ/3/q6XQ8QlRf17UL+MJ3zw5uTYoYZ6LfzC/sCym+ow/R7eN50RegPAIQVz7FW/V/FtxqhnTwjlsogf37+TA8OOcR4Jsg6w/6zJFTST4y89oyXq/m88nPMptpWmHSyGK7Wg5tKqUzvuQKeYW/YOHaOvUWtIO4RVed X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00ec7627-1dff-483c-7f6a-08d97871be5f X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 17:53:37.2114 (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: auBqZSnXVNp+qmx/YXiR2sP2dh1ehdW+OjVSpXXDGj/0s6AL0ddRohZg6AmFR5Ox0FdzmVa1m4zRJDPxTkaNPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1568 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10108 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-2109150105 X-Proofpoint-GUID: v4IUkiFq3A7L96MP7GwmVN-b7FQbPO4w X-Proofpoint-ORIG-GUID: v4IUkiFq3A7L96MP7GwmVN-b7FQbPO4w X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CCD163000100 X-Stat-Signature: pcf3jdg35ihicdymizb4ury9xpzjuam8 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b="Y118mjc/"; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=oYJqXSY7; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=l0fRAhAn; 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: 1631728428-568511 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 17:53:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12497025 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 D7204C433F5 for ; Wed, 15 Sep 2021 17:53:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 75F44611CA for ; Wed, 15 Sep 2021 17:53:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 75F44611CA 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 1E68A6B0074; Wed, 15 Sep 2021 13:53:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1483E6B0075; Wed, 15 Sep 2021 13:53:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDD116B0078; Wed, 15 Sep 2021 13:53:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id DD5346B0074 for ; Wed, 15 Sep 2021 13:53:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A08AD3E578 for ; Wed, 15 Sep 2021 17:53:52 +0000 (UTC) X-FDA: 78590555904.21.2527E41 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf06.hostedemail.com (Postfix) with ESMTP id 22203801A8A7 for ; Wed, 15 Sep 2021 17:53:51 +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 18FH454G011618; Wed, 15 Sep 2021 17:53:47 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=FC3CDR+RmeesGimiizfM0qUR4bmRON7IwaqMVC/gjSw=; b=iSrIVOmNa+m+EQdv9g29+QKODZ1O9cl0dMaXotxlRHbg2CjoZ3Btw8rzhBBd+n79ClrB rGPzm1YeDKpHG6sCjKAjfUzzwEQ1qPSGHl+pfToTi02JY1amIQGAsuOrDrXQNFSpzbvn pDfj/Pobl8aG8Fc0CUqenUyP0IJWRchlenOnhb2PTssqjsaTZyUyL/778ka3qJML+COC XKXFEmxTOHrO/TyLf1+nKwPTjCTYWHJNdLhPAqyPGdIsVKkpLRTCGcotYdqW4D4/V1wf BwXOjnwpxy1tHKT5E0WU1NIl2blatL0t1XsEgpqonCNukgn8p0ApkZCk6jWV4d6gILGB ZQ== 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=FC3CDR+RmeesGimiizfM0qUR4bmRON7IwaqMVC/gjSw=; b=irrXnZlKTBWMJaNXs0s43Bx/VrdCg24TIG7meI2OMAAXkuYhhaSIgOBBSnRN8YZM9zWr r/W7wvsVVpAnORyKDY8VLoBW/ehr8pzyUwdNd9gP4wc2qYwFtZs1AwBZqQH28CmfWnMS nmgVk8NcfFNyUYbwt2mYB+5PMXkMSj1GlJeZG2JHb/QK140Qff3VZe55NWg0JTrvfvEr Xc0vKQUjnG4BgT3J3K+fdYd4UUk8EDdWEpXV53s0AzH02AcbmFgizsyAusnX28wVE+4h 13DJ2FrUJ5L886p39hB589ALclZQx59YJMpVWf6hu0687D4gzuRSao16wCd/C+ez9NKz GA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3b2pygdjjy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 17:53:46 +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 18FHkSNe160992; Wed, 15 Sep 2021 17:53:43 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by aserp3020.oracle.com with ESMTP id 3b0m986m2d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Sep 2021 17:53:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FaOrk7zwq/cDvPA8f3xunohQVdK2G/FBP8FDxmld6xPLzOHf7AaJg+ax80ZF/lNSTMG+ZPF7LYimfjT9T4K7KEuQMhdqmt95UXZ/tYLX5p5Thn9A3QiAfCmJkCcZGwhQuYVi2N/m3kOt6DbbissAk+MkChIcMTvNgYJaTCwhuuyu7hc+1nBtrbn9Nb13zbE2EfxjV2lKgf5cR1ssWGSy987ZZi/QMUHgWiAKC2F/e707oYuGGlJ5WcgoZc0f1HtZ7RjsMXk2QMCwi3WG2cTYfGmhFPhrbCSMqYmNgmUw7heQ+mEikEKaYq5XTV27Bb2o6eENymq9yllC0BIqQoRzDw== 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=FC3CDR+RmeesGimiizfM0qUR4bmRON7IwaqMVC/gjSw=; b=jUnF5hkpAUaeU2vVU9aWDNrgtnztBlDfmaVn7315H+w81JCvpTm5kXnOgW3P1zm7070w81jGYhy5loIXAy3uYnefi3nZgw2lbo0IsEqMngXr6Nxm7h23mszjOFVRwXSApJHk0p9Xu4tKGMa2EyPoHNNxgVvi6JMOYn9dn9DH782Yxtg2RHTPTZT3EsKRtYIoYOAxR1SiCDd6Ab6Ga5RyKQTM+Qfh7uhKgmoS3ar36wTAn95OUeyOS9AMbJ4tKMKPnMeklgO5U1tLKMI6+OVmFJIE/pa+V5vNtv3cbH8sQuY3xbC/n6j5niCqmv9RDs6cGiqiHX2nKQverNlOpjVhiA== 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=FC3CDR+RmeesGimiizfM0qUR4bmRON7IwaqMVC/gjSw=; b=eUx0hfc2ZzEeBtlPxq2EZVRKa2PPTSmMQORFzNmbmFH/TLoDVrj46qEVjuUbsMrwThPUxmEkUGH7SlC71CUgepAsmpu6qMT8DlbEUqOHBxSdjju4bi3zRZdn/t4hhYGvxol3608vvJHgKzjKjZbZQkzlIVEyTs6KxBY0HMLyNN0= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by MWHPR10MB1568.namprd10.prod.outlook.com (2603:10b6:300:26::20) 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 17:53:41 +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 17:53:41 +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 v2 3/3] lib, stackdepot: Add helper to print stack entries into buffer. Date: Thu, 16 Sep 2021 03:53:21 +1000 Message-Id: <20210915175321.3472770-4-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210915175321.3472770-1-imran.f.khan@oracle.com> References: <20210915175321.3472770-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SY6PR01CA0105.ausprd01.prod.outlook.com (2603:10c6:10:111::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 SY6PR01CA0105.ausprd01.prod.outlook.com (2603:10c6:10:111::20) 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 17:53:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0857f70c-1259-42e7-cb43-08d97871c0ef X-MS-TrafficTypeDiagnostic: MWHPR10MB1568: 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: m0dJnxuV61BVEE2rRoIqmNBuJBPY7+YvLaf57jujpTvQJfcdGKtoaIJgy80E5Y6gpvnrGAvfx/3xdWO+5LnmSZbnUPKKUvDPrwv2Zcc2tYXDvv3SZIK6FKBYlPfrCLdMqGoiCCBms10aN90bfyFRSu1Ytte5gNSmPeLYYryDfoDtUAAgJuVrD4Ur0GfqRvTwUQ+HwQrtuWmhO5NhR7q6ALJDgJDzXSZugychmjUU9GykPc6TTmgVA4fnJZw+y0TYZmj561w6XjOh8Gz0uqLZJ+EzevXK2n3gXXtisfsxJZpz9SFcHCjV9RciHqsLcF0wCTZt9siGdD+IuFe6/LIxr/9ImS7DNoB2qYUz1ADhUx497AnKSToH46TJSXMtufGygQw69GrHsgAamAc2r5m15UXVwXHkL0XvLs0f35jMqgSK+a8oACDjjg+OGHZcF1BUxG0ak1sjKqxwaNDw9vLsdUOG9BH0/jsxaTEwU6wsu6VrsYSYJy+ct2sC8K/kNy0tmLPQrsOZXnT1/dZ6DsjShIRSGVusDUggMMc0b7Aa2e9b03ua34YS21nFKjSGYXK5rYOp0HcQS8Q30b4ptSNSbsM+4gruBfdQt0NNWn66YEdXN+EVdgBNhaUb1nFkWho6yQVQj1AOpY9OFX3IFqsVIu8EGO31SYYIuS8XggcovgJhA62/so6c8jaO5J1pmwitH0OeHtdnPBfXnXHL7m0kMRLm5pfbmKvWVei3ijM70ww= 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:(376002)(136003)(39860400002)(396003)(366004)(346002)(6486002)(66556008)(66946007)(2906002)(6666004)(921005)(66476007)(38100700002)(8936002)(6506007)(38350700002)(83380400001)(7416002)(956004)(2616005)(8676002)(26005)(186003)(52116002)(103116003)(36756003)(316002)(86362001)(1076003)(5660300002)(478600001)(6512007)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2inWXrnL2Fa9yhkTcZkzc+kdR4Mnumn0htgy+wn1DbSvpH+QVLloqxEIVYTuLrUjTNftCAhDSFhqxAtd5tY1H/7C8etqORNNSQx9dgn8k7xjKX4MUqe574hOp0LycYq+hw24M/bJi20SO5UFWtLBUkGo657JyrBqQZx/WgfGCEGGxjd33uVN46SwZsi2RYj/4ICFdbxIRDCegK/GJBKdzyI2dJf3R7Te1ibuYiRvUknYx/K0bJgV6T8OIjD9u2Sed4klMJ1xo7spmW/n6XM/t0uli06fJxK2LtGVnEwbYU580ktcFrPRen+gdlMOA9jhbBeW8OowiLkxqzzfLLLIhIjYzJza4I2CvVD+UCG0Rnoi+gNvkfKzeCY065geLo/I2hgSuViCr1HpHgoOxOOx0Xjlt80p7/OLAysZ+v33+GwVfI4fHd41Zc2nIPCg+nDMyTKr2r//5wsRoEAQoSGk4cuxfw1THymuh8WJHbLkBUhLDox34521cqBrhMMd3iWi9+7XyBwyq2g+xfaYOBlKjY5Sa+iO3v/NPgFxMP7yrrE0fe7iOAwhZfPEoVJVUIsmMCpypVGy34tfRMwxOcDhd6Uspq4367nerhBMHnSZek8zji7uGBlAx8hHmqBiY/pthALhJs941diPTY5YIApE9K25r8LzDGo6XNMmK1t8cHLgMs2MRQIdBaCs3i4yE7c6khg6yM4yDZGPu5yMu19gRsBe6DZV5JvLisBg2PmXIpqiyvcqWjcEapKY+qvTvZBhXGrxfW7AWyf9Szucl0l4684i6d4DIQ83qG96unug6eCg/C+hEdJXoZ9gkTdaaB2mA5L47fiFPdlxXDl/KwV0C1CVQugubEAoLNMlNXXB/tZaal7e1MalqRXCmJAbebhcpruEL5fuq0hXNLcTc5XDqVqhss/8beqgeROf0FAntodLdfaRedEuXHKShmK+8cfWmwGhJaTm9noptPhNTJvcvrOWwaug9Vs+5YMeAjQBO93xS+dGHx3AO8kngqQGEl5rskDeQQNyHhWP7Xcn7JX7rjYMo8cvhjIfEEj+rGSaLQLzph/UQ4n/Qh4Xz4DbYH+XvNPv+lOr2Pz1UvfJTrrLMOHDIrFyJz/VVDeG4aRgWUXvIwLfXprzJOYwnBsZMDb9Z6XdXRW2uzlLVtPos+zIm1ocur9B+AKgQGMMI98BmMM+JOvI9MvoWJZcX5iloB+l9kGj9ToduRb4os2kBLWM5nsBK0NkZImaKxHZx71JEDFXtbrVp5+IwU8l3almenbKG+2FdssAVCJgydBh+vDKpVAbiqPP4T0JiR4zUpQBK+SXh23EdfnyFYwxo9jn9BJ/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0857f70c-1259-42e7-cb43-08d97871c0ef X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 17:53:41.4687 (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: tF56ntTIcEKI0DzAcVmQ5ZmFPikH/MxO5BlMb7/XhEBkbKxLLv+KF4QssGvZfn9GdrdPSv3nK0IeYp63lcekAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1568 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10108 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-2109150105 X-Proofpoint-GUID: UW8Padu6tX-5JHoxAtdUDZVa37uy40LA X-Proofpoint-ORIG-GUID: UW8Padu6tX-5JHoxAtdUDZVa37uy40LA X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 22203801A8A7 X-Stat-Signature: ib7yqm9wu97j6857j6qqij6mz5kogufr Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=iSrIVOmN; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b=irrXnZlK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=eUx0hfc2; spf=none (imf06.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: 1631728431-871751 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, 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..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_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..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;