From patchwork Tue Sep 6 06:05:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 12966881 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 80F75ECAAA1 for ; Tue, 6 Sep 2022 06:06:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD7AF8024F; Tue, 6 Sep 2022 02:06:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D87E480224; Tue, 6 Sep 2022 02:06:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C75BF8024F; Tue, 6 Sep 2022 02:06:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B82BF80224 for ; Tue, 6 Sep 2022 02:06:03 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 82F061C6508 for ; Tue, 6 Sep 2022 06:06:03 +0000 (UTC) X-FDA: 79880625006.11.9DA967D Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf27.hostedemail.com (Postfix) with ESMTP id D49AA400A9 for ; Tue, 6 Sep 2022 06:06:02 +0000 (UTC) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28624FXS016898 for ; Mon, 5 Sep 2022 23:06:02 -0700 Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3jc4eymcyf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 05 Sep 2022 23:06:02 -0700 Received: from twshared30313.14.frc2.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 5 Sep 2022 23:06:00 -0700 Received: by devbig932.frc1.facebook.com (Postfix, from userid 4523) id 12669C895177; Mon, 5 Sep 2022 23:05:56 -0700 (PDT) From: Song Liu To: , CC: , Song Liu , Uladzislau Rezki , Baoquan He , Andrew Morton Subject: [PATCH v2] mm/vmalloc: Extend find_vmap_lowest_match_check with extra arguments Date: Mon, 5 Sep 2022 23:05:48 -0700 Message-ID: <20220906060548.1127396-1-song@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: J-LVi1LW7GLLjskZqmIDrTJNHhPW1Skh X-Proofpoint-ORIG-GUID: J-LVi1LW7GLLjskZqmIDrTJNHhPW1Skh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-06_03,2022-09-05_03,2022-06-22_01 ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of "prvs=02488a3979=songliubraving@fb.com" designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=02488a3979=songliubraving@fb.com"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662444363; a=rsa-sha256; cv=none; b=deAW0wm74tMAao5sMgzxPYCMN4xVA1g3VU8XQIKbK8sXP1qKCLN1a3YM7+dWB+y57sIiFi Y8yOBxEc/4S80Iffyq3HMTad4ldhq3e7cnG2D4Joc+1TfztXyO4ddoOtlBNaTPTT+v8oq9 bqbNG5Q172nxBmz22O03nVCs9q51f+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662444363; 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:content-transfer-encoding:in-reply-to: references; bh=mSk0+gLNYGo73/QEITSgRP9xnK/Jt6HEIx9t3a9JHEY=; b=B5s5UUrRooUxOaVN+hwxdtqIvp7xuY09ypshA2S78NzXNWjR0vWq8UHB+eXCO2Lqg8Kmxc Q9+pt3dFzTK8l6rUuPPrfZ0yOpfIolEpZrn/RtTdewLC4HoDZw8WDUS1hvdxJPC79Iiu8a YVelpkoxteOqhCzk8sj8s6wORy/LqgU= Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of "prvs=02488a3979=songliubraving@fb.com" designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=02488a3979=songliubraving@fb.com"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) X-Rspam-User: X-Stat-Signature: ntxpt89qnonq31nk7xs76tx6pzg8dbgo X-Rspamd-Queue-Id: D49AA400A9 X-Rspamd-Server: rspam05 X-HE-Tag: 1662444362-727153 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: find_vmap_lowest_match() is now able to handle different roots. With DEBUG_AUGMENT_LOWEST_MATCH_CHECK enabled as: Reviewed-by: Baoquan He Reviewed-by: Uladzislau Rezki (Sony) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index e68c0081e861..7552f1f8350e 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -713,7 +713,7 @@ EXPORT_SYMBOL(vmalloc_to_pfn); /*** Global kva allocator ***/ -#define DEBUG_AUGMENT_LOWEST_MATCH_CHECK 0 +#define DEBUG_AUGMENT_LOWEST_MATCH_CHECK 1 compilation failed as: mm/vmalloc.c: In function 'find_vmap_lowest_match_check': mm/vmalloc.c:1328:32: warning: passing argument 1 of 'find_vmap_lowest_match' makes pointer from integer without a cast [-Wint-conversion] 1328 | va_1 = find_vmap_lowest_match(size, align, vstart, false); | ^~~~ | | | long unsigned int mm/vmalloc.c:1236:40: note: expected 'struct rb_root *' but argument is of type 'long unsigned int' 1236 | find_vmap_lowest_match(struct rb_root *root, unsigned long size, | ~~~~~~~~~~~~~~~~^~~~ mm/vmalloc.c:1328:9: error: too few arguments to function 'find_vmap_lowest_match' 1328 | va_1 = find_vmap_lowest_match(size, align, vstart, false); | ^~~~~~~~~~~~~~~~~~~~~~ mm/vmalloc.c:1236:1: note: declared here 1236 | find_vmap_lowest_match(struct rb_root *root, unsigned long size, | ^~~~~~~~~~~~~~~~~~~~~~ Extend find_vmap_lowest_match_check() and find_vmap_lowest_linear_match() with extra arguments to fix this. Fixes: f9863be49312 ("mm/vmalloc: extend __alloc_vmap_area() with extra arguments") Cc: Uladzislau Rezki (Sony) Cc: Baoquan He Cc: Andrew Morton Signed-off-by: Song Liu --- Changes v1 => v2: 1. Update commit log to show the error with DEBUG_AUGMENT_LOWEST_MATCH_CHECK. (Uladzislau Rezki, Baoquan He) --- mm/vmalloc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index dd6cdb201195..088b421601c4 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1300,12 +1300,12 @@ find_vmap_lowest_match(struct rb_root *root, unsigned long size, #include static struct vmap_area * -find_vmap_lowest_linear_match(unsigned long size, +find_vmap_lowest_linear_match(struct list_head *head, unsigned long size, unsigned long align, unsigned long vstart) { struct vmap_area *va; - list_for_each_entry(va, &free_vmap_area_list, list) { + list_for_each_entry(va, head, list) { if (!is_within_this_va(va, size, align, vstart)) continue; @@ -1316,7 +1316,8 @@ find_vmap_lowest_linear_match(unsigned long size, } static void -find_vmap_lowest_match_check(unsigned long size, unsigned long align) +find_vmap_lowest_match_check(struct rb_root *root, struct list_head *head, + unsigned long size, unsigned long align) { struct vmap_area *va_1, *va_2; unsigned long vstart; @@ -1325,8 +1326,8 @@ find_vmap_lowest_match_check(unsigned long size, unsigned long align) get_random_bytes(&rnd, sizeof(rnd)); vstart = VMALLOC_START + rnd; - va_1 = find_vmap_lowest_match(size, align, vstart, false); - va_2 = find_vmap_lowest_linear_match(size, align, vstart); + va_1 = find_vmap_lowest_match(root, size, align, vstart, false); + va_2 = find_vmap_lowest_linear_match(head, size, align, vstart); if (va_1 != va_2) pr_emerg("not lowest: t: 0x%p, l: 0x%p, v: 0x%lx\n", @@ -1513,7 +1514,7 @@ __alloc_vmap_area(struct rb_root *root, struct list_head *head, return vend; #if DEBUG_AUGMENT_LOWEST_MATCH_CHECK - find_vmap_lowest_match_check(size, align); + find_vmap_lowest_match_check(root, head, size, align); #endif return nva_start_addr;