From patchwork Wed Jan 10 01:22:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 13515586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3E56C47077 for ; Wed, 10 Jan 2024 01:22:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 419AF6B0087; Tue, 9 Jan 2024 20:22:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CA666B0088; Tue, 9 Jan 2024 20:22:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 293016B008A; Tue, 9 Jan 2024 20:22:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 179BC6B0087 for ; Tue, 9 Jan 2024 20:22:41 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 942DD140A6E for ; Wed, 10 Jan 2024 01:22:40 +0000 (UTC) X-FDA: 81661651680.11.111FA3B Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf28.hostedemail.com (Postfix) with ESMTP id E4C95C001B for ; Wed, 10 Jan 2024 01:22:38 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=WPF3S4aP; spf=pass (imf28.hostedemail.com: domain of 3XfGdZQsKCOoWMXQeTeUZSTSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--kaleshsingh.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3XfGdZQsKCOoWMXQeTeUZSTSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704849758; a=rsa-sha256; cv=none; b=jzOnwnkZTryjvq2Au0SSPSDsyBotFkZ8lODVcyGxx99BV6VuTOYWtY8+WaMw1gcBfCLcuI 4g9hXeLiS3ci61gt9gebzMev3aNZMFnBv2lTzXHBL90s38zGsXYtfBzgzFgkln0xqIIXeU xm1TWXjCRBjCqNuVK73FFpkWhYuaIEI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=WPF3S4aP; spf=pass (imf28.hostedemail.com: domain of 3XfGdZQsKCOoWMXQeTeUZSTSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--kaleshsingh.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3XfGdZQsKCOoWMXQeTeUZSTSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--kaleshsingh.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704849758; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=oxelwYVTfqx3BsJBc98Q1mFz+9jmLLkrSjInccUU7OY=; b=4FsklVGxsiL2wr6cThlVaL9k7TNJpEXzLfLfFbgcR9Y9SEsvXiY/zIWUcpbtWolRlZll0z aSJilEkw10OrbMoz+In7Pi871NldTsoh0cjwiUy2Wncz4x4/J1D79pwjmp58vgZIXpMP5S n/zWmEO6OmMT8oSXSqtkZJ9ePlBJ2UU= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbee47bacb5so4023679276.1 for ; Tue, 09 Jan 2024 17:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704849758; x=1705454558; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=oxelwYVTfqx3BsJBc98Q1mFz+9jmLLkrSjInccUU7OY=; b=WPF3S4aPOU5U5KKT7mWHEs+yHbsFjnJR571/9hnN5kSyXbE+BOZ1eCJhYgsGRalY3C 7PtJnETCCD+iS3BX17v8H5bqlPmxCzdqKFGTrNcMqiU5fdS6FNlrEVgdzOVpbcg/Ww+q FxwmEL5wLdj6NQOKsRzJkcxeY2U4PamVUZ11QvKmsFU7RC7lzST8H0q+YD+W1glTr2B2 jzZkstSQh1BURsb+e/cuLIH3Cv9mLK+FvIBCsF7vSC9W7aRWwfmq4+NEOlEXSv3l1mt/ Ydzou1+EevR9jePKKq107w2iyYNIGNKwAvVRwjNOWMAMgktPiO2iXSB/JZ7eSlELxPsf 6nZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704849758; x=1705454558; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=oxelwYVTfqx3BsJBc98Q1mFz+9jmLLkrSjInccUU7OY=; b=vdBWAbETkF0hQrYbLH4fY1foVQfDKkKn3IvaypHZFxW5x1R0sHbulI3H3XFUE/F1Za KsYWQfLsvnZPJ611nIeBGiUXD4K18d+YqwusaPRmS/VaGZ3OZd7IUeq49DQNgIW2Mf+K KG50w9M2kfoTPQXyHY1i5sABG9mmPiVj9SmfxyJC1bjmh2qB3X9ZPZop6OYWoeAbxTkF K2eos0KCWDeTLjWU7zC2UqKDYfk0F6oU6DtOrHi9gdMFjKwH0Iakw5P8dFCth48C8GV/ eGpn6VSKpIxtyKhrvlNE1Z5d7ziHjiPQHvUWaT1VrgjVDdbUg8HdrNqAl/wAb+GiEvEI b1qg== X-Gm-Message-State: AOJu0Yw9HafDXwuKzyaGej5gbBkRF43RHzDUbJgBcCMtdBqvkx9tvjGP 5wsH2TVnpRhX7L90AmRvBfbsH0preZxTStIziL1K/An4 X-Google-Smtp-Source: AGHT+IEwO3CkIi5BqYZ7/kmBvc2O4ubrd60l4MicjgcfNaoXF4Ph5JwiFjmqNVehIeJw8ttt7GJreAzLDO8sOWM1AA== X-Received: from kalesh.mtv.corp.google.com ([2620:15c:211:201:c35c:511:8258:7aa2]) (user=kaleshsingh job=sendgmr) by 2002:a25:8404:0:b0:dbe:d797:ef35 with SMTP id u4-20020a258404000000b00dbed797ef35mr644980ybk.3.1704849757983; Tue, 09 Jan 2024 17:22:37 -0800 (PST) Date: Tue, 9 Jan 2024 17:22:33 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20240110012234.3793639-1-kaleshsingh@google.com> Subject: [PATCH] mm/cma: Fix placement of trace_cma_alloc_start/finish From: Kalesh Singh To: minchan@kernel.org, akpm@linux-foundation.org, lmark@codeaurora.org Cc: surenb@google.com, android-mm@google.com, kernel-team@android.com, Kalesh Singh , Georgi Djakov , Liam Mark , linux-mm@kvack.org, linux-kernel@vger.kernel.org X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E4C95C001B X-Stat-Signature: s1zqkicd3hdob3odxuu9mbbcrn3j9x41 X-Rspam-User: X-HE-Tag: 1704849758-752462 X-HE-Meta: U2FsdGVkX185ubTpj028NTXMJtuXJXDBhUPPT+ObWFziBflFaXpaxoJLA2Z38oyaDWorq12KLEjgj1KGIlcnsmajjPtE+0vqdH+ronfMzVDlxMMwMLBLnLN37LLB3GqFaZi9Oei5RPk1IvmzZnKSczWX0abNjRuRDGWOBAP+znVF8ZKApoPBfH1vh2PvufPy2c9YmDl2VRkeI4YKAj1s3PsLtzj8E0cmdL5RtA9iQe9rVA9N0Xb+T8qoBARCqj+2RzjL+BOW6K5TSU3gzo3O+G3c8NJEitkuYImwMe0tesT3/YLZdM8/NC0fNCvFW2CsbDGL9ksEJWtJrPw3Xdb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ZCPB32pMqOCD2SyKWlReg8grlBiiMTtWJ+DdaYBHz0d3WB8UGcmnonD3BlC+V9PKY2JqdinMoSdIILPbrsL3QSefCXE0xkoXhIe7ZYxXs8X13r8BIp7064vFWFYoM2wMfNohSFdMRJNsXlV6qqAhW80L+8mZShdCzDfjdWLvi/qtf6M7yTKZheadC08UKXrG4M/mzGONUDmYqna/06hdmTmx3qwgAGTKmPkXN1itIdK6sIwImqftjCONP8rGHlnZpUTy7+0PCW0qiZZzZP4fy0nbRGMCpsW1++tukPHFrSB1glCOe6vJWddgmVJ04GWK6NYsZ+SrHW61IE4U/i3OvjNk7XTEm5olUEXGR7tW3Vff39LHqS6SC0QdOuI2gDmOz1k1N3jeT6XrW1trvZacTF/HxBaohuMPB0r0W4HCFVOvReUe23UwH+yvFcBFhdBWunDiTdCTrUIVlYdQ== 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: List-Subscribe: List-Unsubscribe: The current placement of trace_cma_alloc_start/finish misses the fail cases: !cma || !cma->count || !cma->bitmap. trace_cma_alloc_finish is also not emitted for the failure case where bitmap_count > bitmap_maxno. Fix these missed cases by moving the start event before the failure checks and moving the finish event to the out label. Fixes: 7bc1aec5e287 ("mm: cma: add trace events for CMA alloc perf testing") Cc: Minchan Kim Cc: Andrew Morton Cc: Liam Mark Signed-off-by: Kalesh Singh --- mm/cma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) base-commit: 0dd3ee31125508cd67f7e7172247f05b7fd1753a diff --git a/mm/cma.c b/mm/cma.c index 2b2494fd6b59..8341f1217a85 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -436,6 +436,9 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, unsigned long i; struct page *page = NULL; int ret = -ENOMEM; + const char *name = cma ? cma->name : NULL; + + trace_cma_alloc_start(name, count, align); if (!cma || !cma->count || !cma->bitmap) goto out; @@ -446,8 +449,6 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, if (!count) goto out; - trace_cma_alloc_start(cma->name, count, align); - mask = cma_bitmap_aligned_mask(cma, align); offset = cma_bitmap_aligned_offset(cma, align); bitmap_maxno = cma_bitmap_maxno(cma); @@ -496,8 +497,6 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, start = bitmap_no + mask + 1; } - trace_cma_alloc_finish(cma->name, pfn, page, count, align, ret); - /* * CMA can allocate multiple page blocks, which results in different * blocks being marked with different tags. Reset the tags to ignore @@ -516,6 +515,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, pr_debug("%s(): returned %p\n", __func__, page); out: + trace_cma_alloc_finish(name, pfn, page, count, align, ret); if (page) { count_vm_event(CMA_ALLOC_SUCCESS); cma_sysfs_account_success_pages(cma, count);