From patchwork Tue Aug 31 06:25:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imran Khan X-Patchwork-Id: 12466511 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.6 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 6DE6CC4320E for ; Tue, 31 Aug 2021 06:26:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E1A5C6023F for ; Tue, 31 Aug 2021 06:26:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E1A5C6023F 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 808FE6B0073; Tue, 31 Aug 2021 02:26:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B6C26B0074; Tue, 31 Aug 2021 02:26:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E26B8D0001; Tue, 31 Aug 2021 02:26:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id 4A4156B0073 for ; Tue, 31 Aug 2021 02:26:01 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id F32638249980 for ; Tue, 31 Aug 2021 06:26:00 +0000 (UTC) X-FDA: 78534390480.16.6FB6D76 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf15.hostedemail.com (Postfix) with ESMTP id 8384BD000096 for ; Tue, 31 Aug 2021 06:26:00 +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 17V4guLa016422; Tue, 31 Aug 2021 06:25:59 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=jEbc+xPe252FsXlJUozVeaJUXOhtA+iiaJNek2TeIbg=; b=KuZgadt34/nAfeuc+InIVcWP8VkfiITllGwZqccDuykl2V3jp6AMJvja1JssEfmVItkj gXJm5kRFnPlKileVErwgnhVDVjn2NaL1BOsq+I1bC5IWbSaxVPrny5RsktHT+cSgoNZG vqRJ3A7ednsx5jArui+fsAD0tqdG+i63NCSzAbIVwqtoJGtRtyZQgb7Vk9tdfN6Cw4I5 TEj9VXUegXC0MteVAKKEGPac9q/aiQ4g2Tho/eMw7FAdXlz06RrUKyQuBS1tDaM1Y3Ed h/VX4oD503NlFTCmWiUvPGCFjJYpyUTd9aBABRjgQ9ldE2YXwkyP/I77gNleXlckzVZy yA== 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=jEbc+xPe252FsXlJUozVeaJUXOhtA+iiaJNek2TeIbg=; b=oYlkf/C7+2bJjJ0D18xYQbfLQsIcJF0L1zB9tpBmJ2FbDznvQsIsiOvRtWRaM01v0Abc Xg3hgd0SWa8ad71uGNHAxHgXcsTNLoo/fTPi+nVk5hYxOyfOOqoF2ljxKE39bo4CVn5p nXajCUOVVG+tjTZ+6nBVc8SI/jwL+1LcZGSdJ+jcHj+Ii7E5rbs03vfgxNEyULxyqOmu Hj4RpurGnb9qyaggh8Kbe9y0QF/lzZ6gHxHeuuMoOChR9DLZ5Kw0wvTqq3gwdvosOnRn S5BzGxGfyExuHF6dUCJzIxX3IkSkVxEzkNhQHpHDkWGNx6tsoTuEk1VCUFkkTL7i1iee bQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3asdn1r5kn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Aug 2021 06:25:59 +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 17V6Fb1B119159; Tue, 31 Aug 2021 06:25:58 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by aserp3020.oracle.com with ESMTP id 3aqcy459cu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Aug 2021 06:25:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ftu1Uolx1qoaifVkfd15PYK8VdnQPNySPvhKnKLjlhC4zdO/xRLOGbBsOoOvLnUUMPXq6qK8s1oI/55qx3AsBTwpGCpqZcmZKY1Rz9EeSLSXTnihaRhZNL9BVy344iu2Nj27XOYZi5y5VMRrLSnpthYu6tBE3PiheVCR6kBgEPJJ0jx3XDd9yNF/9G0VGS8jDuCh6vo/DmoAPU+8bp40NSxJyTRhxakI//UiPdSnR9mnr7gh+6n5FVmB+cQCwsDjknmzrnheTYJT62JE58FOSGBuK+PEhEzYpou91p/tnA0nr0m1vau8IhQmX5aTRhlriRW7R/ur8+8l+k7exKGagQ== 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:X-MS-Exchange-SenderADCheck; bh=jEbc+xPe252FsXlJUozVeaJUXOhtA+iiaJNek2TeIbg=; b=TsrKi4uqe2RN+5dVl4081fEbBlezCR5+O5PwsP5iEXpD5Zw7RmqINd7pea3AZrJ/UxobIJNjmhuq4QtajjwRA5IrTJQnvCF0HC+Z4OpZ/fJEmAthJOaReofMSkCEANxz57DVgeuMVTDW9OJLxToxOf9Yf6IAFKRfDdVHs8AneN2I4IhqusFb+iaw1/XUi4InBPKglqU/ARzbIDi1bdJX7jA9dX3+4ANmnqAczRgdqMuBwyZKNvQuKXh2w0n24oDy0Tal+WCFFLjiCrKU28do2C+1ROLCVDfk3dLqIeBaa5aoRodqY8nJzuGMdbE8R3SJfm+buHh9Yu1Li8RLZcNlQA== 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=jEbc+xPe252FsXlJUozVeaJUXOhtA+iiaJNek2TeIbg=; b=ESoaP7r5mJYrhAbBi4zEKq7mLWTekrhCvHBieWhaqlgYZOtrofgtvmj1kKI5SJ44vtLEhLUqFDXEFzVAwtMzalBvMZrqcp1dPTWIWOmRs02anmQVcYQBU5KAQy17GpNMyofWky0vrh5PldVk4AjwwXNWepBmthZ5KGMarajfE9s= Received: from CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) by MWHPR10MB1999.namprd10.prod.outlook.com (2603:10b6:300:10a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.23; Tue, 31 Aug 2021 06:25:56 +0000 Received: from CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::c8e:2147:b83f:79db]) by CO1PR10MB4468.namprd10.prod.outlook.com ([fe80::c8e:2147:b83f:79db%8]) with mapi id 15.20.4457.024; Tue, 31 Aug 2021 06:25:56 +0000 From: Imran Khan To: cl@linux.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/2] mm, slub: Use stackdepot to store user information for slub object. Date: Tue, 31 Aug 2021 16:25:39 +1000 Message-Id: <20210831062539.898293-3-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210831062539.898293-1-imran.f.khan@oracle.com> References: <20210831062539.898293-1-imran.f.khan@oracle.com> X-ClientProxiedBy: SYCPR01CA0009.ausprd01.prod.outlook.com (2603:10c6:10:31::21) To CO1PR10MB4468.namprd10.prod.outlook.com (2603:10b6:303:6c::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (110.33.47.182) by SYCPR01CA0009.ausprd01.prod.outlook.com (2603:10c6:10:31::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.19 via Frontend Transport; Tue, 31 Aug 2021 06:25:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb158f36-e64e-42ca-3cd5-08d96c483108 X-MS-TrafficTypeDiagnostic: MWHPR10MB1999: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:499; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YIw/7bodPDaeM44YZ/LLPiGxt4JBG1VjJwTxVS8pmFzKCCAIXOopxkEY5uq2DUpUPCyH9raEbe+X32NBJOyWxZn9fs6007s3VqCSrAnkOCMNspbs6aU2hoq/gxyPgd2/T47t3GkA3i/QGe6JNyHbHhkggof8nYsL4Q80SGG/zPIBYdrKL9YAUxCkwyySZkarP2yh9WmKx4T69Bf2rMR1rzrUlPAl26q6R3uAqtybdIC1lr2zlwxW8fUChUdkK9OldHgMDrT9y2s0ij/ZUz8JkOd34GRo+euW3WC74fYlMBO9IyR41FBYeiBO58sPA9SQRfPUnJCeX/H3RcK5HucFzvjBFb8Zq3Ill334mNRPDlf4J5xBFFMgd9c4vfqDspdk+GXKsuGMYYy5qk9ssLEtvY2i0LdTAjZOGrcJSuEXCoIZaqDy6W38fxH0s5l/cDoctCfkvGJ4tlNjbDy/ACzbpoxmBGRvuAf5OgJQoAnNzmXiT23Nv+7qQ4I4+y+mPQdkeqzueI61tujxWiNWW3te7EA0NOqTMncSEM45XiYDgkjtAfdKO/+3A7b9thIZW5S4XA20mdNiwtdBVDTYCHMdLJH4Nn/0FEbwc2B6j3jedfYDGbyJa5m6kCPJIQ92np9bBDmovw5bh9j8fgKr6kgZq9XGCgclamhsH64Jk9KWSPX+sl0EOLPPdRFtxkAb8hnYNA/glQKVE/r38aJydwbCXg== 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)(39860400002)(396003)(136003)(366004)(346002)(2906002)(956004)(316002)(86362001)(2616005)(5660300002)(66946007)(83380400001)(36756003)(1076003)(4326008)(6666004)(66556008)(66476007)(8936002)(6506007)(6486002)(52116002)(38100700002)(38350700002)(8676002)(26005)(186003)(478600001)(6512007)(103116003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6uZoL84Ipe9YqM0SZMpOR1oUMHE/FFBSZj/aYmScjxPjTykxYB0dtzddQSIBWUJoBoTENPQQiU1Wf825a6WGxtGntA4G1nIL7OaLo/Y4PsXLLDWEda6tadw2DaGRqErrZt2MpjFWm4mlCHsD6/Jp+tj4gPVT7FomRZMoVDRMmETTv5zNwKUP6yftN6JdOaCfM9Cd7FzQlGEdob0hTrknTshRMIP24pftUY1bmxzgxoH8wqgZKrHbPxoJQq7Z7/tWysrekimG4zgaouFnOMYwXzJago2gnoxP8wpS3ZcpDavi73ph3HZ9XjBKQp4o0aaDzjD+LI5HbphtwIKkooG4crmvXdaWCgvVYNdtACsWVB/sOk0UMTbTNQ9XPDOLZ06T55YHI9wu1izJoB3Ug3ARnRtELdX0XCcs4qIMUNjLIJvfQ18chYmqAbV6xeNNHkbllrwrmsvyDkocNWzGf3bv+OHTZgc0HEl0YSFMf7h7eY1GZDtEI2Y/2Lb/Vmut1cdKsgvNU3ZOKU95ZLafjlvBDEVx0cNnEl4CRRbD3oyCxohkSxMFPa2p8qxvnKtnlTogJwt9W8Hx6Sz3Bsbn2OAmWCcbeYoFIsSCr5U8kpJxxecBqJTH6xmSl2zY4r/8xT3stH85M2VsUXTbiqoYLYqq8U2A+AilE3z5y5SXCYHURNtyD2nrn1luAzMhzZDjtv5HX3eZe2S033xARSVJe/lnYVM6f8bPKw4Tknz2TFKsCDukOvA/JPDZ7RFJfC5Jurv93+hRx/7Few+2e/KNeXITure4fjCSczSlBS8b1rgKqSZIVuqqrxNyhn9wOHotYKcXAE3xVk0pQknOKeHuMFxlocHQia7ZGsbhOGcAQmFhO/6a3svIik8tmIR5w5YKXCXwhuSj6A0reRmjUMxQjnjnTkJr8dKTWsh0oON1+w4YuJxoSYwO7TML92Y0ajy3UiSEkxCFn0a0TyyppiIJm5Ni848CVPKYUGOjKPs4eOnwA3Xha2OpwjKQwIiw4rvrPvO8c6MP/mY4jsGsZ26xtSvWij/ubwPcgTF1loK5Q6gpPk24sNqnFC5weA48Tg+iPMOv6bwDz4bHrjI9IzKnxjPvGxbjRVIygSF7UKzl7EJjC8zKYQVs/IEfKcdXc8y5sVGVfUmrsjYkyI8DmzNQv/gy9BuYOgowX6sZWz0O7aviBCenHM61t4JJJ9y4UooXo3Z63Hb9whREKt1zV16xLonVZihf7EiIKhpsb/YIyfuRVaiZlJp+ABvOWEWU7SkcT1/G9Hui7xcmm+4MWKDvE1p2wWaF0djnsHMducIBW+Ma+q3J4mOXHKdQhz5T3F9JkuJk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb158f36-e64e-42ca-3cd5-08d96c483108 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4468.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2021 06:25:56.6819 (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: P8pGhTgu6Rf5fQKhZ9L6IJFF5Nysw0SbBatwEBT0OuFJOrGHUrKaoxmbtJgCOG3rXz1AHw/qxmPQbs6aWtU/UQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1999 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10092 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108310036 X-Proofpoint-ORIG-GUID: 36uYU2Fqdf2FNvQriWcxk4PNCHIYJY6P X-Proofpoint-GUID: 36uYU2Fqdf2FNvQriWcxk4PNCHIYJY6P Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=KuZgadt3; dkim=pass header.d=oracle.com header.s=corp-2020-01-29 header.b="oYlkf/C7"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ESoaP7r5; spf=none (imf15.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: urmedjb14tzetskj587jrjy3yujtc3zr X-Rspamd-Queue-Id: 8384BD000096 X-Rspamd-Server: rspam04 X-HE-Tag: 1630391160-361970 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: SLAB_STORE_USER causes information about allocating and freeing context of a slub object, to be stored in metadata area in a couple of struct track objects. These objects store allocation and/or freeing stack trace in an array. This may result in same stack trace getting stored in metadata area of multiple objects. STACKDEPOT can be used to store unique stack traces without any duplication,so use STACKDEPOT to store allocation and/or freeing stack traces as well. This results in low memory footprint, as we are not storing multiple copies of the same stack trace for an allocation or free. Signed-off-by: Imran Khan --- mm/slub.c | 87 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index df1ac8aff86f..8e2a2b837106 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -264,8 +264,8 @@ static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s) #define TRACK_ADDRS_COUNT 16 struct track { unsigned long addr; /* Called from address */ -#ifdef CONFIG_STACKTRACE - unsigned long addrs[TRACK_ADDRS_COUNT]; /* Called from address */ +#ifdef CONFIG_STACKDEPOT + depot_stack_handle_t stack; #endif int cpu; /* Was running on cpu */ int pid; /* Pid context */ @@ -668,6 +668,27 @@ static inline unsigned int get_info_end(struct kmem_cache *s) return s->inuse; } +#ifdef CONFIG_STACKDEPOT +static depot_stack_handle_t slub_debug_save_stack(gfp_t flags) +{ + unsigned long entries[TRACK_ADDRS_COUNT]; + unsigned int nr_entries; + + nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 4); + nr_entries = filter_irq_stacks(entries, nr_entries); + return stack_depot_save(entries, nr_entries, flags); +} + +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); +} +#endif + static struct track *get_track(struct kmem_cache *s, void *object, enum track_item alloc) { @@ -679,21 +700,13 @@ static struct track *get_track(struct kmem_cache *s, void *object, } static void set_track(struct kmem_cache *s, void *object, - enum track_item alloc, unsigned long addr) + enum track_item alloc, unsigned long addr, gfp_t flags) { struct track *p = get_track(s, object, alloc); if (addr) { -#ifdef CONFIG_STACKTRACE - unsigned int nr_entries; - - metadata_access_enable(); - nr_entries = stack_trace_save(kasan_reset_tag(p->addrs), - TRACK_ADDRS_COUNT, 3); - metadata_access_disable(); - - if (nr_entries < TRACK_ADDRS_COUNT) - p->addrs[nr_entries] = 0; +#ifdef CONFIG_STACKDEPOT + p->stack = slub_debug_save_stack(flags); #endif p->addr = addr; p->cpu = smp_processor_id(); @@ -709,10 +722,11 @@ static void init_tracking(struct kmem_cache *s, void *object) if (!(s->flags & SLAB_STORE_USER)) return; - set_track(s, object, TRACK_FREE, 0UL); - set_track(s, object, TRACK_ALLOC, 0UL); + set_track(s, object, TRACK_FREE, 0UL, 0U); + set_track(s, object, TRACK_ALLOC, 0UL, 0U); } + static void print_track(const char *s, struct track *t, unsigned long pr_time) { if (!t->addr) @@ -720,15 +734,11 @@ static void print_track(const char *s, struct track *t, unsigned long pr_time) pr_err("%s in %pS age=%lu cpu=%u pid=%d\n", s, (void *)t->addr, pr_time - t->when, t->cpu, t->pid); -#ifdef CONFIG_STACKTRACE - { - int i; - for (i = 0; i < TRACK_ADDRS_COUNT; i++) - if (t->addrs[i]) - pr_err("\t%pS\n", (void *)t->addrs[i]); - else - break; - } +#ifdef CONFIG_STACKDEPOT + if (t->stack) + print_stack(t->stack); + else + pr_err("(stack is not available)\n"); #endif } @@ -1261,7 +1271,8 @@ static inline int alloc_consistency_checks(struct kmem_cache *s, static noinline int alloc_debug_processing(struct kmem_cache *s, struct page *page, - void *object, unsigned long addr) + void *object, unsigned long addr, + gfp_t flags) { if (s->flags & SLAB_CONSISTENCY_CHECKS) { if (!alloc_consistency_checks(s, page, object)) @@ -1270,7 +1281,7 @@ static noinline int alloc_debug_processing(struct kmem_cache *s, /* Success perform special debug activities for allocs */ if (s->flags & SLAB_STORE_USER) - set_track(s, object, TRACK_ALLOC, addr); + set_track(s, object, TRACK_ALLOC, addr, flags); trace(s, page, object, 1); init_object(s, object, SLUB_RED_ACTIVE); return 1; @@ -1350,7 +1361,7 @@ static noinline int free_debug_processing( } if (s->flags & SLAB_STORE_USER) - set_track(s, object, TRACK_FREE, addr); + set_track(s, object, TRACK_FREE, addr, GFP_NOWAIT); trace(s, page, object, 0); /* Freepointer not overwritten by init_object(), SLAB_POISON moved it */ init_object(s, object, SLUB_RED_INACTIVE); @@ -2987,7 +2998,7 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node, check_new_page: if (kmem_cache_debug(s)) { - if (!alloc_debug_processing(s, page, freelist, addr)) { + if (!alloc_debug_processing(s, page, freelist, addr, gfpflags)) { /* Slab failed checks. Next slab needed */ goto new_slab; } else { @@ -4275,6 +4286,8 @@ void kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct page *page) void *objp0; struct kmem_cache *s = page->slab_cache; struct track __maybe_unused *trackp; + unsigned long __maybe_unused *entries; + unsigned int __maybe_unused nr_entries; kpp->kp_ptr = object; kpp->kp_page = page; @@ -4297,19 +4310,15 @@ void kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct page *page) objp = fixup_red_left(s, objp); trackp = get_track(s, objp, TRACK_ALLOC); kpp->kp_ret = (void *)trackp->addr; -#ifdef CONFIG_STACKTRACE - for (i = 0; i < KS_ADDRS_COUNT && i < TRACK_ADDRS_COUNT; i++) { - kpp->kp_stack[i] = (void *)trackp->addrs[i]; - if (!kpp->kp_stack[i]) - break; - } +#ifdef CONFIG_STACKDEPOT + nr_entries = stack_depot_fetch(trackp->stack, &entries); + for (i = 0; i < nr_entries; i++) + kpp->kp_stack[i] = (void *)entries[i]; trackp = get_track(s, objp, TRACK_FREE); - for (i = 0; i < KS_ADDRS_COUNT && i < TRACK_ADDRS_COUNT; i++) { - kpp->kp_free_stack[i] = (void *)trackp->addrs[i]; - if (!kpp->kp_free_stack[i]) - break; - } + nr_entries = stack_depot_fetch(trackp->stack, &entries); + for (i = 0; i < nr_entries; i++) + kpp->kp_free_stack[i] = (void *)entries[i]; #endif #endif }