From patchwork Wed Jan 24 18:09:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13529522 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 C7A62C48260 for ; Wed, 24 Jan 2024 18:09:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84F9D8D000A; Wed, 24 Jan 2024 13:09:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FE878D0001; Wed, 24 Jan 2024 13:09:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C6AC8D000A; Wed, 24 Jan 2024 13:09:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5C1478D0001 for ; Wed, 24 Jan 2024 13:09:28 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2B281140418 for ; Wed, 24 Jan 2024 18:09:28 +0000 (UTC) X-FDA: 81714992016.12.30BADAC Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf13.hostedemail.com (Postfix) with ESMTP id 21BE720024 for ; Wed, 24 Jan 2024 18:09:25 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Hp/EjpjW"; spf=pass (imf13.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.50 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706119766; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NTk+QOHhuV0ddu1f13MxSI+SyTG7OrguLkgzhrD1Zbc=; b=lF/oI1nrdMl8UzzWjPz5FFHdYFlbcsqR2hD1URHQHDq5RMpGzneBYD8RuKg03L915Sl3A/ vjc3XzgRbOZJfiOtySW0PDiSbxVdAkc+AZxskOIouEIdVNAOsuKDjHQ0Q849+b5Zpu/MyD TpDYxMfTUX8LGicJQPW4YQiZbaBHzwU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706119766; a=rsa-sha256; cv=none; b=M/UWOIX5oeoENO3MBlFEjFUP9yD+DFwMJ7gqx8F+SyACkn4PbIYtMNbkYJumJt3GrWCR/U siJ221FhSJmafFqU5vRLx1E11o60Wye+4czLCvp49Uj2aFcU7gfNP9DvrLqkIRKN9uR/G3 GvOma17G24m690tULQo1XdzQYO2hgj8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Hp/EjpjW"; spf=pass (imf13.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.50 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-50e7d6565b5so7275432e87.0 for ; Wed, 24 Jan 2024 10:09:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706119764; x=1706724564; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NTk+QOHhuV0ddu1f13MxSI+SyTG7OrguLkgzhrD1Zbc=; b=Hp/EjpjWFZw+Lb6idXYW/37ycLJLpGsBgTXSnRVnrSnGUCKul9eIOOLc1VEWfph0iK 5WWoU2hBBf2XB3xdqG34KC+b6S9nta3OhjuWdMlSeKl5cZPPm4fyqmu5EbEttKdFCjmy 1kUQA48+MunxlHA1tGT6c3Q7pPCFu3pgcnxYQRM2H4zCD64wPPBEfAPncwtBrzVXxnga UcH70CwOLlHoGEDQzPQUB9ob2ky2einxtCyBJSa6/1ffXNacHkEmtOX+Y1rFTG+l37RT 2FptcP+I/p35ImJmV9G7tb3uEOChm5s08xgSuVcCYp8hbd6pj+dodJwFsLu41VAvnbFp xR4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706119764; x=1706724564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NTk+QOHhuV0ddu1f13MxSI+SyTG7OrguLkgzhrD1Zbc=; b=w22bfliJog1gEg3oZ7vlWKRXFgwD13W1WZiZcxjdaNM55HobLHsYNioIJUbZRmOQOf mkxF3BZ7I+Vg+UFUa4DvoY/Shc0oWHTXvagva/hhBZk4WGMrH2fP0DS8MjdUc6vAtH1x kxDTQrEfkdUvVtFAXGlWXXS90to52dZKWnfKyJHurFUhtYisW/zSRRpV6hI0Yq8NDWPm DQKGYtIoRAlmLVp8pwIjNKt/nxM2nEJ4/9EmusZ36EyAf4GlswmIAvrplZ6XOZzzcIHd +a1fvgtshKxbFnai5D+x9C23ZCMpa1ZWo9uqPw7QkpM6UOPnzsKuW2szemptbn92vqqn xPJw== X-Gm-Message-State: AOJu0YyBuxM9YpA9uLOPy2BWfkNWP6YOFGOGr8XX3bIkw+yBZVUJACMZ 1bKyRNr/Ry1ogxmjZGYJtzJA2TXfHiq+f1seM4DvzxgW7gterJ/19scJuz5E X-Google-Smtp-Source: AGHT+IGHrDb2JJILi44pZF1bRFKMJXwjxb22K3MOoBAwdNnQSWTxUg4T9nOIRqxBVMxOQ1FEBZ0Gag== X-Received: by 2002:a05:6512:3991:b0:50e:b3bb:1292 with SMTP id j17-20020a056512399100b0050eb3bb1292mr4221934lfu.74.1706119764350; Wed, 24 Jan 2024 10:09:24 -0800 (PST) Received: from pc638.lan (host-185-121-47-193.sydskane.nu. [185.121.47.193]) by smtp.gmail.com with ESMTPSA id k16-20020a05651239d000b0050eaec14596sm2656667lfu.39.2024.01.24.10.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 10:09:24 -0800 (PST) From: "Uladzislau Rezki (Sony)" To: linux-mm@kvack.org, Andrew Morton Cc: LKML , Baoquan He , Lorenzo Stoakes , Christoph Hellwig , Matthew Wilcox , Dave Chinner , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 2/2] mm: vmalloc: Refactor vmalloc_dump_obj() function Date: Wed, 24 Jan 2024 19:09:20 +0100 Message-Id: <20240124180920.50725-2-urezki@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240124180920.50725-1-urezki@gmail.com> References: <20240124180920.50725-1-urezki@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 21BE720024 X-Rspam-User: X-Stat-Signature: xbhe5z9rmmuy7pzxc9ihbyd1fs1wtw7g X-Rspamd-Server: rspam03 X-HE-Tag: 1706119765-52767 X-HE-Meta: U2FsdGVkX18BcKqCXaGHpAmKRB8pyNlKrrLYIJNV0xghyEE/x2K9yNE56QIg4aGbdF/Lvr+rRIBcefuo4DM5RHf34TSm+GvA/UvpNk7XNmK0J69Yc7czB8R4treUwgLbO3V2Np2j3gRnqLpojI2K3lDnzdAmmoehhwWhAhch1JQEuFRNrcZF7yVbSj0ggE0POp+Z/LD4jt9P4vwolK2pGKKMYjbs6cXISXHtVpy0lgV7iB9LtIefG2REqHO55nF6lP+rPqpJhyhJT21OisiiE/AMtfsaCckK4l//cNM6tSsX/A3gCvLH1Ul/xF0BzK4QgY8QI+SnKucRTNeoV8kwET8uPn5Tf2R7hwkV5S0N5B8s4jNR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Ajks+W7+KUHQNWzgcW3fk4XB9BEtJU= 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: This patch tends to simplify the function in question, by removing an extra stack "objp" variable, returning back to an early exit approach if spin_trylock() fails or VA was not found. Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes --- mm/vmalloc.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index b8be601b056d..449f45b0e474 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4696,34 +4696,35 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) #ifdef CONFIG_PRINTK bool vmalloc_dump_obj(void *object) { - void *objp = (void *)PAGE_ALIGN((unsigned long)object); const void *caller; + struct vm_struct *vm; struct vmap_area *va; struct vmap_node *vn; unsigned long addr; unsigned int nr_pages; - bool success = false; - - vn = addr_to_node((unsigned long)objp); - if (spin_trylock(&vn->busy.lock)) { - va = __find_vmap_area((unsigned long)objp, &vn->busy.root); + addr = PAGE_ALIGN((unsigned long) object); + vn = addr_to_node(addr); - if (va && va->vm) { - addr = (unsigned long)va->vm->addr; - caller = va->vm->caller; - nr_pages = va->vm->nr_pages; - success = true; - } + if (!spin_trylock(&vn->busy.lock)) + return false; + va = __find_vmap_area(addr, &vn->busy.root); + if (!va || !va->vm) { spin_unlock(&vn->busy.lock); + return false; } - if (success) - pr_cont(" %u-page vmalloc region starting at %#lx allocated at %pS\n", - nr_pages, addr, caller); + vm = va->vm; + addr = (unsigned long) vm->addr; + caller = vm->caller; + nr_pages = vm->nr_pages; + spin_unlock(&vn->busy.lock); - return success; + pr_cont(" %u-page vmalloc region starting at %#lx allocated at %pS\n", + nr_pages, addr, caller); + + return true; } #endif