From patchwork Tue Jun 7 09:34:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 12871634 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 08595C433EF for ; Tue, 7 Jun 2022 09:35:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51C8F8D0007; Tue, 7 Jun 2022 05:35:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CAB68D0001; Tue, 7 Jun 2022 05:35:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E5E98D0007; Tue, 7 Jun 2022 05:35:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0618A8D0001 for ; Tue, 7 Jun 2022 05:35:03 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CC7D9C5F for ; Tue, 7 Jun 2022 09:35:02 +0000 (UTC) X-FDA: 79550930844.30.607FA2F Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by imf03.hostedemail.com (Postfix) with ESMTP id 8A8712005D for ; Tue, 7 Jun 2022 09:34:45 +0000 (UTC) Received: by mail-lf1-f51.google.com with SMTP id s6so27339884lfo.13 for ; Tue, 07 Jun 2022 02:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/m93af/b5jfm9tZCfE4d8bYwXKExf/KtRK6sqDTZnX8=; b=d1Bn/bBj18RiG2Wo96aBwJlqBTl0eZb5+qmlzXXE6bQ+j8QfHZ6T7KzicQVAnczhwv gZu8VrkgcEUhaK5xIMDA4Y//j1RTSK5dRGhgw1DiaCnbgUkqsN6OdWJ+OxA2b0xx+utk dBgTvwQWP9erRmmJFn2tug3I6XFqkTKy03Wa/lXo402QokGda0DaI/w+4lEn57lgfj1G 3mD8WFfvQXHZuH5WTBMGd+HiF60kOnZYpeXyvu7m0eMycc142U4fus5IJyzevNlp/0yH D0jC/jxOGhyI8IGiBhw27bMaA5LtqMANjtCDqnUsi5G3MXWrWEItVhFN+qfpoSvw1UtE ZY2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/m93af/b5jfm9tZCfE4d8bYwXKExf/KtRK6sqDTZnX8=; b=nKxrH3uHXOW5a/hMerPbXlmTfDcbY2Tiuk1W2i6m5+CwCi+guFlZraIuW8iVUwLnj5 Yzqf6RIGUdczmil/7gRm0jnHFLdMZCafv+B0ywsmUa6UyN0NUVPEHCcJ+5VMrKJCqOt3 301OFhaGHIhn2DGBPSa8gP2MEeVyNjlHQx9obHp74vsAe4Nk7NECIKddqT5xw37U+9zA iU0dFamBhd8byCZgHWOCwDKc8RIKAcgeFU9RnspHTOtUQ+AsIy5lTJaCBE7AQOom1RIW VKpcGkLhcRYtM8en2S03Yc62YD2UnuGXaR1FT5Z4XIsOHWIehk4qes8aO9Abwhqkn/va Fuyg== X-Gm-Message-State: AOAM532RLXjpI6f26aIhEJOiOehR2Anbpx65iFWY9y2on9vHrRahwgDZ T66rpzIwm8YsxTeRrXk6cHoZNW+b7q8glg== X-Google-Smtp-Source: ABdhPJyVkUcTCv4+l8aPtPwj+grbnTiZq6vPqAsaIkKbrR3qe7PRUtUNv/A07lVdkcB0uZl4/17oLA== X-Received: by 2002:a05:6512:2622:b0:478:f29d:8197 with SMTP id bt34-20020a056512262200b00478f29d8197mr23728997lfb.513.1654594500741; Tue, 07 Jun 2022 02:35:00 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id r27-20020a2e575b000000b002554a4ebf5fsm2748043ljd.74.2022.06.07.02.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:35:00 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Christoph Hellwig , Matthew Wilcox , Nicholas Piggin , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 1/5] mm/vmalloc: Make link_va()/unlink_va() common to different rb_root Date: Tue, 7 Jun 2022 11:34:45 +0200 Message-Id: <20220607093449.3100-2-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220607093449.3100-1-urezki@gmail.com> References: <20220607093449.3100-1-urezki@gmail.com> MIME-Version: 1.0 X-Stat-Signature: ufkuqz7m8qx19h1g1szrjphj893jzcoc Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="d1Bn/bBj"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.51 as permitted sender) smtp.mailfrom=urezki@gmail.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 8A8712005D X-HE-Tag: 1654594485-351657 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: Currently link_va() and unlik_va(), in order to figure out a tree type, compares a passed root value with a global free_vmap_area_root variable to distinguish the augmented rb-tree from a regular one. It is hard coded since such functions can manipulate only with specific "free_vmap_area_root" tree that represents a global free vmap space. Make it common by introducing "_augment" versions of both internal functions, so it is possible to deal with different trees. There is no functional change as a result of this patch. Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Baoquan He --- mm/vmalloc.c | 60 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index be8ed06804a5..0102d6d5fcdf 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -911,8 +911,9 @@ get_va_next_sibling(struct rb_node *parent, struct rb_node **link) } static __always_inline void -link_va(struct vmap_area *va, struct rb_root *root, - struct rb_node *parent, struct rb_node **link, struct list_head *head) +__link_va(struct vmap_area *va, struct rb_root *root, + struct rb_node *parent, struct rb_node **link, + struct list_head *head, bool augment) { /* * VA is still not in the list, but we can @@ -926,7 +927,7 @@ link_va(struct vmap_area *va, struct rb_root *root, /* Insert to the rb-tree */ rb_link_node(&va->rb_node, parent, link); - if (root == &free_vmap_area_root) { + if (augment) { /* * Some explanation here. Just perform simple insertion * to the tree. We do not set va->subtree_max_size to @@ -950,12 +951,28 @@ link_va(struct vmap_area *va, struct rb_root *root, } static __always_inline void -unlink_va(struct vmap_area *va, struct rb_root *root) +link_va(struct vmap_area *va, struct rb_root *root, + struct rb_node *parent, struct rb_node **link, + struct list_head *head) +{ + __link_va(va, root, parent, link, head, false); +} + +static __always_inline void +link_va_augment(struct vmap_area *va, struct rb_root *root, + struct rb_node *parent, struct rb_node **link, + struct list_head *head) +{ + __link_va(va, root, parent, link, head, true); +} + +static __always_inline void +__unlink_va(struct vmap_area *va, struct rb_root *root, bool augment) { if (WARN_ON(RB_EMPTY_NODE(&va->rb_node))) return; - if (root == &free_vmap_area_root) + if (augment) rb_erase_augmented(&va->rb_node, root, &free_vmap_area_rb_augment_cb); else @@ -965,6 +982,18 @@ unlink_va(struct vmap_area *va, struct rb_root *root) RB_CLEAR_NODE(&va->rb_node); } +static __always_inline void +unlink_va(struct vmap_area *va, struct rb_root *root) +{ + __unlink_va(va, root, false); +} + +static __always_inline void +unlink_va_augment(struct vmap_area *va, struct rb_root *root) +{ + __unlink_va(va, root, true); +} + #if DEBUG_AUGMENT_PROPAGATE_CHECK /* * Gets called when remove the node and rotate. @@ -1060,7 +1089,7 @@ insert_vmap_area_augment(struct vmap_area *va, link = find_va_links(va, root, NULL, &parent); if (link) { - link_va(va, root, parent, link, head); + link_va_augment(va, root, parent, link, head); augment_tree_propagate_from(va); } } @@ -1077,8 +1106,8 @@ insert_vmap_area_augment(struct vmap_area *va, * ongoing. */ static __always_inline struct vmap_area * -merge_or_add_vmap_area(struct vmap_area *va, - struct rb_root *root, struct list_head *head) +__merge_or_add_vmap_area(struct vmap_area *va, + struct rb_root *root, struct list_head *head, bool augment) { struct vmap_area *sibling; struct list_head *next; @@ -1140,7 +1169,7 @@ merge_or_add_vmap_area(struct vmap_area *va, * "normalized" because of rotation operations. */ if (merged) - unlink_va(va, root); + __unlink_va(va, root, augment); sibling->va_end = va->va_end; @@ -1155,16 +1184,23 @@ merge_or_add_vmap_area(struct vmap_area *va, insert: if (!merged) - link_va(va, root, parent, link, head); + __link_va(va, root, parent, link, head, augment); return va; } +static __always_inline struct vmap_area * +merge_or_add_vmap_area(struct vmap_area *va, + struct rb_root *root, struct list_head *head) +{ + return __merge_or_add_vmap_area(va, root, head, false); +} + static __always_inline struct vmap_area * merge_or_add_vmap_area_augment(struct vmap_area *va, struct rb_root *root, struct list_head *head) { - va = merge_or_add_vmap_area(va, root, head); + va = __merge_or_add_vmap_area(va, root, head, true); if (va) augment_tree_propagate_from(va); @@ -1348,7 +1384,7 @@ adjust_va_to_fit_type(struct vmap_area *va, * V NVA V * |---------------| */ - unlink_va(va, &free_vmap_area_root); + unlink_va_augment(va, &free_vmap_area_root); kmem_cache_free(vmap_area_cachep, va); } else if (type == LE_FIT_TYPE) { /* From patchwork Tue Jun 7 09:34:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 12871635 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 7C98EC43334 for ; Tue, 7 Jun 2022 09:35:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25AAF8D0008; Tue, 7 Jun 2022 05:35:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 20B268D0001; Tue, 7 Jun 2022 05:35:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 083CC8D0008; Tue, 7 Jun 2022 05:35:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EDC6E8D0001 for ; Tue, 7 Jun 2022 05:35:03 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B07DB3397F for ; Tue, 7 Jun 2022 09:35:03 +0000 (UTC) X-FDA: 79550930886.09.43554BC Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by imf29.hostedemail.com (Postfix) with ESMTP id 3FAEA120068 for ; Tue, 7 Jun 2022 09:34:48 +0000 (UTC) Received: by mail-lf1-f48.google.com with SMTP id a15so27373148lfb.9 for ; Tue, 07 Jun 2022 02:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5rMhy7+1gkAH7mug47fF5ZHhc0+p0pd9emNDGCWCkpQ=; b=W+JslE4xHQ3jMlYH2KXGmvWlZnLm/+4nJq/39GMb+2a3O8zXVrnEwptgEjNTBXWLXy Vb7PId2j2ByR/FNZXN71Tz4LMaIxEVrtf+tkuQeW14h/R//OWPOG1o23t5kIfL7Us8IS yrT6QyUs0taloEBjoqzxVjvZ0ToYoXS5o+8lY4SVo5Ei3kPEGMgP5oDcVg66Gwq8EyDo Spmc/f8XAkvXhwByc0/wn0IdYpFXvvfL2RWJ/2re53TVpVT3+CiuuX6hVLYF8y7uthwh yIt47aSh4oS9+eT/7zmQ8Auy1cd3HRfsNEhgTrUb4d+dUpmrp+gM1o6cds4HBcW/r32y Us6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5rMhy7+1gkAH7mug47fF5ZHhc0+p0pd9emNDGCWCkpQ=; b=hpbxAvLFYZvdt0+kMpGIapxMlgncBhfS5xcstKIs6vi+/6qXVjxuMahSgvNwsZXGUQ AnERgedYAnQHOxb6UBMXplJWTGO0wyjrqbkKFsPQT2KPQ8ZNiJeCe+Z2PdMdEJgGaRKr GW4IQ1UBATPsybFnW+NAjN5uMpcvT03WIeCNjhA08+JV+4AqQS0lFrBM9YDPbqGlG2+n qnC4MxOokSGS2mf9bpMt1cxKqOqXu5Tk/iwU/V7fZse+YuZnUJS/rDiCuH06KzTRfOxe HZOmNLan2XNuUczR6x4XbRoHULy0s0rAD47ent9C87Fl2HGpCMpTovvqBgpsGMU6vRqt OonA== X-Gm-Message-State: AOAM531qjnpzs9Mutf5G/zCtbm/M1Eo4Kjqo1F243mKeE+hLn6hk2fxC EOeTpsY7d829b56KkKZ7t6McMxbMMmZ6Wg== X-Google-Smtp-Source: ABdhPJzoedISnY2HZsN02qxifFxKqIIvrfom4dgYI59hEBCxocGEgX5giTqS91rcUcFjlqDshWY4jA== X-Received: by 2002:a05:6512:3f0a:b0:477:b1f8:1a40 with SMTP id y10-20020a0565123f0a00b00477b1f81a40mr66936199lfa.343.1654594501675; Tue, 07 Jun 2022 02:35:01 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id r27-20020a2e575b000000b002554a4ebf5fsm2748043ljd.74.2022.06.07.02.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:35:01 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Christoph Hellwig , Matthew Wilcox , Nicholas Piggin , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 2/5] mm/vmalloc: Extend __alloc_vmap_area() with extra arguments Date: Tue, 7 Jun 2022 11:34:46 +0200 Message-Id: <20220607093449.3100-3-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220607093449.3100-1-urezki@gmail.com> References: <20220607093449.3100-1-urezki@gmail.com> MIME-Version: 1.0 X-Stat-Signature: 57cebo413y77pca17hofop5sxf3njp3n X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=W+JslE4x; spf=pass (imf29.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.48 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3FAEA120068 X-HE-Tag: 1654594488-725804 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: It implies that __alloc_vmap_area() allocates only from the global vmap space, therefore a list-head and rb-tree, which represent a free vmap space, are not passed as parameters to this function and are accessed directly from this function. Extend the __alloc_vmap_area() and other dependent functions to have a possibility to allocate from different trees making an interface common and not specific. There is no functional change as a result of this patch. Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Baoquan He --- mm/vmalloc.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 0102d6d5fcdf..745e89eb6ca1 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1234,15 +1234,15 @@ is_within_this_va(struct vmap_area *va, unsigned long size, * overhead. */ static __always_inline struct vmap_area * -find_vmap_lowest_match(unsigned long size, unsigned long align, - unsigned long vstart, bool adjust_search_size) +find_vmap_lowest_match(struct rb_root *root, unsigned long size, + unsigned long align, unsigned long vstart, bool adjust_search_size) { struct vmap_area *va; struct rb_node *node; unsigned long length; /* Start from the root. */ - node = free_vmap_area_root.rb_node; + node = root->rb_node; /* Adjust the search size for alignment overhead. */ length = adjust_search_size ? size + align - 1 : size; @@ -1370,9 +1370,9 @@ classify_va_fit_type(struct vmap_area *va, } static __always_inline int -adjust_va_to_fit_type(struct vmap_area *va, - unsigned long nva_start_addr, unsigned long size, - enum fit_type type) +adjust_va_to_fit_type(struct rb_root *root, struct list_head *head, + struct vmap_area *va, unsigned long nva_start_addr, + unsigned long size, enum fit_type type) { struct vmap_area *lva = NULL; @@ -1384,7 +1384,7 @@ adjust_va_to_fit_type(struct vmap_area *va, * V NVA V * |---------------| */ - unlink_va_augment(va, &free_vmap_area_root); + unlink_va_augment(va, root); kmem_cache_free(vmap_area_cachep, va); } else if (type == LE_FIT_TYPE) { /* @@ -1462,8 +1462,7 @@ adjust_va_to_fit_type(struct vmap_area *va, augment_tree_propagate_from(va); if (lva) /* type == NE_FIT_TYPE */ - insert_vmap_area_augment(lva, &va->rb_node, - &free_vmap_area_root, &free_vmap_area_list); + insert_vmap_area_augment(lva, &va->rb_node, root, head); } return 0; @@ -1474,7 +1473,8 @@ adjust_va_to_fit_type(struct vmap_area *va, * Otherwise a vend is returned that indicates failure. */ static __always_inline unsigned long -__alloc_vmap_area(unsigned long size, unsigned long align, +__alloc_vmap_area(struct rb_root *root, struct list_head *head, + unsigned long size, unsigned long align, unsigned long vstart, unsigned long vend) { bool adjust_search_size = true; @@ -1495,7 +1495,7 @@ __alloc_vmap_area(unsigned long size, unsigned long align, if (align <= PAGE_SIZE || (align > PAGE_SIZE && (vend - vstart) == size)) adjust_search_size = false; - va = find_vmap_lowest_match(size, align, vstart, adjust_search_size); + va = find_vmap_lowest_match(root, size, align, vstart, adjust_search_size); if (unlikely(!va)) return vend; @@ -1514,7 +1514,7 @@ __alloc_vmap_area(unsigned long size, unsigned long align, return vend; /* Update the free vmap_area. */ - ret = adjust_va_to_fit_type(va, nva_start_addr, size, type); + ret = adjust_va_to_fit_type(root, head, va, nva_start_addr, size, type); if (ret) return vend; @@ -1605,7 +1605,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, retry: preload_this_cpu_lock(&free_vmap_area_lock, gfp_mask, node); - addr = __alloc_vmap_area(size, align, vstart, vend); + addr = __alloc_vmap_area(&free_vmap_area_root, &free_vmap_area_list, + size, align, vstart, vend); spin_unlock(&free_vmap_area_lock); /* @@ -3886,7 +3887,8 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets, /* It is a BUG(), but trigger recovery instead. */ goto recovery; - ret = adjust_va_to_fit_type(va, start, size, type); + ret = adjust_va_to_fit_type(&free_vmap_area_root, + &free_vmap_area_list, va, start, size, type); if (unlikely(ret)) goto recovery; From patchwork Tue Jun 7 09:34:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 12871636 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 EF1ADC433EF for ; Tue, 7 Jun 2022 09:35:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D85418D0009; Tue, 7 Jun 2022 05:35:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CDFE08D0001; Tue, 7 Jun 2022 05:35:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B338D8D0009; Tue, 7 Jun 2022 05:35:04 -0400 (EDT) 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 9CEFE8D0001 for ; Tue, 7 Jun 2022 05:35:04 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 79889CCD for ; Tue, 7 Jun 2022 09:35:04 +0000 (UTC) X-FDA: 79550930928.28.11CC14C Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by imf17.hostedemail.com (Postfix) with ESMTP id B1BB240014 for ; Tue, 7 Jun 2022 09:34:23 +0000 (UTC) Received: by mail-lf1-f45.google.com with SMTP id u23so27415794lfc.1 for ; Tue, 07 Jun 2022 02:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KoD0FJtvAYiro/wAlRb5zLOAm2ljSVphawX93yu7smo=; b=lTqaQnN6yqJuFg22PrQ1ychCB7duFlShGXgJcYA3YXTZ23/6rCXn89SZzsVCCuXNwk fAyAPiksl8n+YyODYbm60Hd4oRw3NqyoehccHyocO3M5pUWDoZJ+uOfLV7auvKjwedeG pgJO752qd9Vvj9NdJGo0Iv9fCCIZg1NEkfTBLDMCry64TNpUFu0GvHHRUEcQpj4q2hIu 772fHfD/oM1dD0AFUusJoVNawrxrMrKudVN4B2argH2tKTHdVFCUco6bLGjusSs5xmfq ZuVO0jNoebGgeiyb26jyQCnjn8c9ciStTmHRcqYLEfe/i01YDdaInFg+xEK4FUA09ZPU Ad7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KoD0FJtvAYiro/wAlRb5zLOAm2ljSVphawX93yu7smo=; b=jEz3IB6cMyq5eXllEBFWg/wtP5O6dtWGCbiKPKCSfnLhRaX0Be+ZFuSEWc494py2W4 7o7twx04dequtm3PXBAksYnBW3H1UVTv51D6EYXzE0CBL5k7G5MxK3d94E9hwvCiv1B8 S0053Vc9zyyHAbXIMaKt7iIhpXctLHulRmwLrwELjKNY9uLAl8YpAcuLkcpKXC9WtdQo Y4XJ5OojjYwc7HpXaUbKIOjwMMnSEMDL8LyeVDetEsNcjp6dXAjdJKYj6p4CUs/vqx0x m4Z8GBWCF3DOi6MJRRcgrHeFDz45JQOLV3EcyECMC6zAx0cjUpB55+0xI1MhAFlMsnTj Y0AQ== X-Gm-Message-State: AOAM5304TjILvqJJMy2m4QnrNzHx9ASJj7PwRfoW8QoPayFqqOmA90rG BU5iK8nJkJYiFoB0Rtdp66Y= X-Google-Smtp-Source: ABdhPJz+nEYe43ymsAQpZtJHQ1/MvaMOMA/s21VY0MJGYYJhjcHNnEvXn54O9Datx6yzWQULld4+1g== X-Received: by 2002:a05:6512:3502:b0:476:c68d:8b0d with SMTP id h2-20020a056512350200b00476c68d8b0dmr18657838lfs.113.1654594502769; Tue, 07 Jun 2022 02:35:02 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id r27-20020a2e575b000000b002554a4ebf5fsm2748043ljd.74.2022.06.07.02.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:35:02 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Christoph Hellwig , Matthew Wilcox , Nicholas Piggin , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 3/5] mm/vmalloc: Initialize VA's list node after unlink Date: Tue, 7 Jun 2022 11:34:47 +0200 Message-Id: <20220607093449.3100-4-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220607093449.3100-1-urezki@gmail.com> References: <20220607093449.3100-1-urezki@gmail.com> MIME-Version: 1.0 X-Stat-Signature: 85zf8t9bshysm9ux7yipguiocd7oacig Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lTqaQnN6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.45 as permitted sender) smtp.mailfrom=urezki@gmail.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B1BB240014 X-HE-Tag: 1654594463-602470 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: A vmap_area can travel between different places. For example attached/detached to/from different rb-trees. In order to prevent fancy bugs, initialize a VA's list node after it is removed from the list, so it pairs with VA's rb_node which is also initialized. There is no functional change as a result of this patch. Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Baoquan He --- mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 745e89eb6ca1..82771e555273 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -978,7 +978,7 @@ __unlink_va(struct vmap_area *va, struct rb_root *root, bool augment) else rb_erase(&va->rb_node, root); - list_del(&va->list); + list_del_init(&va->list); RB_CLEAR_NODE(&va->rb_node); } From patchwork Tue Jun 7 09:34:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 12871637 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 98397C43334 for ; Tue, 7 Jun 2022 09:35:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A994A8D000A; Tue, 7 Jun 2022 05:35:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A25578D0001; Tue, 7 Jun 2022 05:35:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89B088D000A; Tue, 7 Jun 2022 05:35:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 79D148D0001 for ; Tue, 7 Jun 2022 05:35:05 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 58DE720C3C for ; Tue, 7 Jun 2022 09:35:05 +0000 (UTC) X-FDA: 79550930970.31.19095AD Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by imf15.hostedemail.com (Postfix) with ESMTP id 9DF0AA0047 for ; Tue, 7 Jun 2022 09:34:38 +0000 (UTC) Received: by mail-lf1-f54.google.com with SMTP id t25so27362518lfg.7 for ; Tue, 07 Jun 2022 02:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1imnAi5xz7HqCapEhh8k4KqTLfM1rDshD69OorDTV3Q=; b=FUe9hoC2gjsIGPJVEps761z94HHtbSP1LOQ6MOwoWAKATBaoen37ggvBdmhCO/1Dum bbL9wrYkQmZn5AFVSvqe7rIa4w9PVKkiXXig9eo+xADy33IXOFhyk8i7zMef75DgfAtF jWLLcPerKOjLVHT/t3gqLFTldCmrOvYRPaBzZMiNcUGk5R+FRdJy1YwX/KhRUom+U2/A DsIG8C52yvsQbR5nK0UpenU11Tf/PharFyrCbvu2QYv3HpGWk6uE6m5Ofoq1vk+hAz1a TsH4UPB9OMAyuBrQXofmV+miPQHfnsjtpErZBJ/kZrFD7q3l26g8RK0tKkPYDTKpM0px U2XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1imnAi5xz7HqCapEhh8k4KqTLfM1rDshD69OorDTV3Q=; b=pnAHo/r/GveljN3LW4CRNTsSK7xlEG2j2di96yFZvfMgK5UBvURZaKXqryzh+2d8RT /pbw9DVX09+coHZFlg1xqBbwNFkmMUExckFH+MSddyx1Ke8adl/4jmPiysa2tTxoI+TP MGIno7n9VccYPRRU87XLLIj+5ljcFAJF2OIktEQyAoOae5J/4WJezxccLSmEngFGgEZt /GVHCEdqfQPgNpVt87aj7Li3rX85j6LA279G19PZ8dpvudhGy9pmLnn6d1fTsvE7UBTB l9r45Ug/rpnbwmnXIx3y/m7mnSQzs/DG3zKh9sY0ovbXo+3WWZKJfEdQ0VnY5Ie661Ft d/JA== X-Gm-Message-State: AOAM531EeB6q1ANfBjvbEP3hd5UqBnbHSfh/aQ23whLIRQVy55riBUB3 zMRcMcLYSl6Zp5IO8MjAHno= X-Google-Smtp-Source: ABdhPJwUtUjYWUsi2A0Gz+SKLSqewTZ8rOUEGsOboyqIoXV8szQIuSCZZkSiPZcSm6rDEt2nEkryUQ== X-Received: by 2002:a05:6512:2351:b0:479:6c3b:5d4 with SMTP id p17-20020a056512235100b004796c3b05d4mr526524lfu.87.1654594503595; Tue, 07 Jun 2022 02:35:03 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id r27-20020a2e575b000000b002554a4ebf5fsm2748043ljd.74.2022.06.07.02.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:35:03 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Christoph Hellwig , Matthew Wilcox , Nicholas Piggin , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 4/5] mm/vmalloc: Extend __find_vmap_area() with one more argument Date: Tue, 7 Jun 2022 11:34:48 +0200 Message-Id: <20220607093449.3100-5-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220607093449.3100-1-urezki@gmail.com> References: <20220607093449.3100-1-urezki@gmail.com> MIME-Version: 1.0 X-Stat-Signature: j6up1tyis3jeftz75ujszgbncnbc6x8m Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FUe9hoC2; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.54 as permitted sender) smtp.mailfrom=urezki@gmail.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 9DF0AA0047 X-HE-Tag: 1654594478-122455 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_area() finds a "vmap_area" based on passed address. It scan the specific "vmap_area_root" rb-tree. Extend the function with one extra argument, so any tree can be specified where the search has to be done. There is no functional change as a result of this patch. Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Baoquan He --- mm/vmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 82771e555273..b60385101897 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -814,9 +814,9 @@ static struct vmap_area *find_vmap_area_exceed_addr(unsigned long addr) return va; } -static struct vmap_area *__find_vmap_area(unsigned long addr) +static struct vmap_area *__find_vmap_area(unsigned long addr, struct rb_root *root) { - struct rb_node *n = vmap_area_root.rb_node; + struct rb_node *n = root->rb_node; addr = (unsigned long)kasan_reset_tag((void *)addr); @@ -1840,7 +1840,7 @@ static struct vmap_area *find_vmap_area(unsigned long addr) struct vmap_area *va; spin_lock(&vmap_area_lock); - va = __find_vmap_area(addr); + va = __find_vmap_area(addr, &vmap_area_root); spin_unlock(&vmap_area_lock); return va; @@ -2582,7 +2582,7 @@ struct vm_struct *remove_vm_area(const void *addr) might_sleep(); spin_lock(&vmap_area_lock); - va = __find_vmap_area((unsigned long)addr); + va = __find_vmap_area((unsigned long)addr, &vmap_area_root); if (va && va->vm) { struct vm_struct *vm = va->vm; From patchwork Tue Jun 7 09:34:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 12871638 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 AD1B4C433EF for ; Tue, 7 Jun 2022 09:35:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 086828D000B; Tue, 7 Jun 2022 05:35:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2BF68D0001; Tue, 7 Jun 2022 05:35:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D561C8D000B; Tue, 7 Jun 2022 05:35:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BB7658D0001 for ; Tue, 7 Jun 2022 05:35:06 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8C4A033D8B for ; Tue, 7 Jun 2022 09:35:06 +0000 (UTC) X-FDA: 79550931012.20.4EA28D3 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by imf09.hostedemail.com (Postfix) with ESMTP id 2087614001A for ; Tue, 7 Jun 2022 09:34:49 +0000 (UTC) Received: by mail-lj1-f169.google.com with SMTP id b12so7543163ljq.3 for ; Tue, 07 Jun 2022 02:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O9Luysd5PeLuzQcmOTrN0C4TCxyraTACP2lGutp0njA=; b=OEFcGHiOWs02B1U8ZYucL+4EF4y74Ze4l8dk9hmWMK3FoD023sKgQyHBsewvH7pJJl YvTh8LFtnuzqGOI9PLLplzSzXYJZFK1gYVHuzABkUbwQsoGxgOQgNEusCnjNcnFvnjkd Yl9vUMntxnBPqg1POJJlwrG5civzSjESScL8j/tnlRVv2mn5cmcGkdIeLN7YA/CbyZav 2YVtDUw6X4+2rEN7OA2BrLqdkiZyumlkDfUd5zqAO5M+qMIjTDWVTlyAICItcGoGiyLT YBlyritdBTzazGnA/7VDfcoiLM939ljQagYCiIs7486TAFH38GeJvgIxpjgwoKGRT33Y +CYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O9Luysd5PeLuzQcmOTrN0C4TCxyraTACP2lGutp0njA=; b=JBg18xrV0GkDZmFoSvOZyHQVAr4FoPei/PyBP8uAOWCoKeRqFolx9+PhxgBsAeCA+V VfGmL+wF/kzk2gKnO/HY1A1cjXfjLmHt+3XmTXcXarJRYkma9GKG3RrH91oZzMRDq4Ap Lh+JlS8qW7gvwU9m/g6J2+MFyVGyPsIvEMr2rj0RMBTS2wXnLpmJA3S+STmt1MVyjgZI ifV5AmD/unFLgrvTPcBrcQ593rhs9LrNK2/ozoW3QsAuXfZgB7Q7FMtgZklHzzxNVN4H uTwucS0YA8UOAVzyUjKjXkx05UchuknWTr0AZuzbSDx5OwvClPpe8a2SMjKSEbz2o/kT APqA== X-Gm-Message-State: AOAM532dhkzKz+C9e7is1qdinsPXSfWFhBAAldyFzkmFiXB5dJif042P HnCH4u3XfchL4Dn4R/GNzgE= X-Google-Smtp-Source: ABdhPJwUTjbgFpjRhKBjUdEBBKYoMmoQ2FYhd4s1qcIF4yVZY8JkiVy+ymXc7TQCD8Ki1L7N7af7eQ== X-Received: by 2002:a2e:946:0:b0:255:8750:dfeb with SMTP id 67-20020a2e0946000000b002558750dfebmr9193023ljj.421.1654594504568; Tue, 07 Jun 2022 02:35:04 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id r27-20020a2e575b000000b002554a4ebf5fsm2748043ljd.74.2022.06.07.02.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 02:35:04 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton Cc: linux-mm@kvack.org, LKML , Christoph Hellwig , Matthew Wilcox , Nicholas Piggin , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 5/5] lib/test_vmalloc: Switch to prandom_u32() Date: Tue, 7 Jun 2022 11:34:49 +0200 Message-Id: <20220607093449.3100-6-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220607093449.3100-1-urezki@gmail.com> References: <20220607093449.3100-1-urezki@gmail.com> MIME-Version: 1.0 X-Stat-Signature: 7zzjtxp5tz7gwwztpi9s8s7kasbjnbtx X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OEFcGHiO; spf=pass (imf09.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.169 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2087614001A X-HE-Tag: 1654594489-715330 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: A get_random_bytes() function can cause a high contention if it is called across CPUs simultaneously. Because it shares one lock per all CPUs: class name con-bounces contentions waittime-min waittime-max waittime-total waittime-avg acq-bounces acquisitions holdtime-min holdtime-max holdtime-total holdtime-avg &crng->lock: 663145 665886 0.05 8.85 261966.66 0.39 7188152 13731279 0.04 11.89 2181582.30 0.16 ----------- &crng->lock 307835 [<00000000acba59cd>] _extract_crng+0x48/0x90 &crng->lock 358051 [<00000000f0075abc>] _crng_backtrack_protect+0x32/0x90 ----------- &crng->lock 234241 [<00000000f0075abc>] _crng_backtrack_protect+0x32/0x90 &crng->lock 431645 [<00000000acba59cd>] _extract_crng+0x48/0x90 Switch from the get_random_bytes() to prandom_u32() that does not have any internal contention when a random value is needed for the tests. The reason is to minimize CPU cycles introduced by the test-suite itself from the vmalloc performance metrics. Signed-off-by: Uladzislau Rezki (Sony) --- lib/test_vmalloc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c index cf41fd6df42a..4f2f2d1bac56 100644 --- a/lib/test_vmalloc.c +++ b/lib/test_vmalloc.c @@ -74,12 +74,13 @@ test_report_one_done(void) static int random_size_align_alloc_test(void) { - unsigned long size, align, rnd; + unsigned long size, align; + unsigned int rnd; void *ptr; int i; for (i = 0; i < test_loop_count; i++) { - get_random_bytes(&rnd, sizeof(rnd)); + rnd = prandom_u32(); /* * Maximum 1024 pages, if PAGE_SIZE is 4096. @@ -150,7 +151,7 @@ static int random_size_alloc_test(void) int i; for (i = 0; i < test_loop_count; i++) { - get_random_bytes(&n, sizeof(i)); + n = prandom_u32(); n = (n % 100) + 1; p = vmalloc(n * PAGE_SIZE); @@ -294,14 +295,14 @@ pcpu_alloc_test(void) for (i = 0; i < 35000; i++) { unsigned int r; - get_random_bytes(&r, sizeof(i)); + r = prandom_u32(); size = (r % (PAGE_SIZE / 4)) + 1; /* * Maximum PAGE_SIZE */ - get_random_bytes(&r, sizeof(i)); - align = 1 << ((i % 11) + 1); + r = prandom_u32(); + align = 1 << ((r % 11) + 1); pcpu[i] = __alloc_percpu(size, align); if (!pcpu[i]) @@ -396,7 +397,7 @@ static void shuffle_array(int *arr, int n) int i, j; for (i = n - 1; i > 0; i--) { - get_random_bytes(&rnd, sizeof(rnd)); + rnd = prandom_u32(); /* Cut the range. */ j = rnd % i;