Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4354835img; Tue, 26 Mar 2019 07:53:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmclc+vImlWfZBpAbUOnJ06onf+81pqxkg7gfT2JQa5sgvKL2eAHd6LJ9zNu0iXheaacP7 X-Received: by 2002:aa7:8841:: with SMTP id k1mr29929883pfo.115.1553611992990; Tue, 26 Mar 2019 07:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553611992; cv=none; d=google.com; s=arc-20160816; b=hOPouctajvmsFZh+dy6CAmer8QknqXEbxR+/gGFq2lR8doQla3lw+S+eM0Vv+UP3my gB4cUwbMBfGLHVSwcDOsJyHux2wPn63um2+k5i8SWleiplNjoXaNIp7dMSGtDUJTQoqe VmoC0uyZUY0ICMTEJH6h/mLHB40bL+djIAHskdjguqznNLBNkwGt8o0Go3KEDRm5zus8 GlW7CohClE+Yv4dD1oy9C+yFUY9UkijDX7n3i8DwndaBAzYD+yJQUQxFUoPhovVhQCgU RPJ8WpgiyCdL5fGJdCXHOp1P10yT4Shl9KS66yOjrkjH/iipQgxMTqET7jzKg0lGSK+d EyZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=XI8nG9Dzmt5ShimcJLgUrFfOlr1UjZ/4vfezN58z7mI=; b=W5gGri1qfY2NwTpuj5JslB77UXR+cqXx9AoHBU8amOR5GiSGxrZKRzUgnBBhKdPtsn WLHdOk9av1y6H4kelOe9kV1xRMtgeRnpVTW/ltfAJbCEWsg8FBG5mBeomY1xZfCF5aTq T6ZKBrsl9RnYU56DIjQ9MZKDthPS/E7VMo441pqbdJPiOWsK/mHNupdqZvU3yNeCEFf3 FHi7yGuziVPKEdxN0XK3FltOFRB+0+ezk1uJJyu/Kk0/iO9zdB6ixPYsKsvQot3MyFKo 9cl7YqsbsQbk5ZgY6ylsjw6okDdnkVHoIUvD3FPUiyeyS8SS+FXETObokjowsx/p+kl0 WEsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mtRExl5r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si17756602pld.156.2019.03.26.07.52.56; Tue, 26 Mar 2019 07:53:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mtRExl5r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731707AbfCZOwD (ORCPT + 99 others); Tue, 26 Mar 2019 10:52:03 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:38573 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726111AbfCZOwD (ORCPT ); Tue, 26 Mar 2019 10:52:03 -0400 Received: by mail-lj1-f195.google.com with SMTP id p14so10412577ljg.5 for ; Tue, 26 Mar 2019 07:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XI8nG9Dzmt5ShimcJLgUrFfOlr1UjZ/4vfezN58z7mI=; b=mtRExl5rQvp5nbXGCI/zHz/hSZxZNfiZyNqO8FojEpmtvcCqNgzb3mRjnpamZQpWW1 K+OA4pLUbXctnOw0xvAiKD02hDCUZfrUw71JcmXKz/mqRJCXsvCpSj/+3/KGT3+5+8eh r2sLoGsjsor9eNEnoOIzMKNlos+7JfVp57yi62KnmvFjoB/uNd9J/1yl7Q3y1rjPHEgO TuK1VMYuXbA09G7aFW3F0IZPrMpQru4ZFRCakwwB6slytwAsXVG9WwFVEVp8Y9F2Gb0k Yzf0P9fLan8AXDY5nSAb11qnf+GkkzITTpGXt+nGctYowVFX3P3Bkeq9oD3wYv3qymgD 7Uow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=XI8nG9Dzmt5ShimcJLgUrFfOlr1UjZ/4vfezN58z7mI=; b=grDH+DgAJSrmMNu7JcLarcrykbcsqh5AKoXy+D2KDn267QRpvjApQSBRoxi3Yupqmj hcRrP8jd0aEohRoZVHoIhaYE4FXWasVjup97xhqybTsz90yxZGmyESJhaLL+0Ev+Zh7S 3WTk0PdvnPNesNsXZ7i8l4ORBc/SEMGS5jrfXlL1K7Z8jKHZyKxnrL8VS/6anP+C2rnI 2zFy5KhYu9m/K8WtdEyS7MsJrlaktFQBhNX/5qP0FkFPM2V4EnXaNZqCQr+gdAunmOHK endqlcSWuZJF00qQZY4045XHjbwAHgqARTJ6ZKu17jvRG/F2Ynz65EQ9UkXwdE9HaP+Y xamA== X-Gm-Message-State: APjAAAUzLpldAqbfV6kWkbvSvt50m5c/n2rVPcBi+xW4zng7Lj7V6GXN mwHhL2n/YLD3TYiVsvCqh5Y= X-Received: by 2002:a2e:9655:: with SMTP id z21mr16910027ljh.60.1553611921190; Tue, 26 Mar 2019 07:52:01 -0700 (PDT) Received: from pc636 ([37.139.158.167]) by smtp.gmail.com with ESMTPSA id y1sm4118474ljj.13.2019.03.26.07.51.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Mar 2019 07:52:00 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 26 Mar 2019 15:51:53 +0100 To: Uladzislau Rezki Cc: Roman Gushchin , Andrew Morton , Michal Hocko , Matthew Wilcox , "linux-mm@kvack.org" , LKML , Thomas Garnier , Oleksiy Avramchenko , Steven Rostedt , Joel Fernandes , Thomas Gleixner , Ingo Molnar , Tejun Heo Subject: Re: [RFC PATCH v2 1/1] mm/vmap: keep track of free blocks for vmap allocation Message-ID: <20190326145153.r7y3llwtvqsg4r2s@pc636> References: <20190321190327.11813-1-urezki@gmail.com> <20190321190327.11813-2-urezki@gmail.com> <20190322215413.GA15943@tower.DHCP.thefacebook.com> <20190325172010.q343626klaozjtg4@pc636> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190325172010.q343626klaozjtg4@pc636> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Roman. > > > > So, does it mean that this function always returns two following elements? > > Can't it return a single element using the return statement instead? > > The second one can be calculated as ->next? > > > Yes, they follow each other and if you return "prev" for example you can easily > refer to next. But you will need to access "next" anyway. I would rather keep > implementation, because it strictly clear what it return when you look at this > function. > > But if there are some objections and we can simplify, let's discuss :) > > > > + } > > > + } else { > > > + /* > > > + * The red-black tree where we try to find VA neighbors > > > + * before merging or inserting is empty, i.e. it means > > > + * there is no free vmap space. Normally it does not > > > + * happen but we handle this case anyway. > > > + */ > > > + *prev = *next = &free_vmap_area_list; > > > > And for example, return NULL in this case. > > > Then we will need to check in the __merge_or_add_vmap_area() that > next/prev are not NULL and not head. But i do not like current implementation > as well, since it is hardcoded to specific list head. > Like you said, it is more clever to return only one element, for example next. After that just simply access to the previous one. If nothing is found return NULL. static inline struct list_head * __get_va_next_sibling(struct rb_node *parent, struct rb_node **link) { struct list_head *list; if (likely(parent)) { list = &rb_entry(parent, struct vmap_area, rb_node)->list; return (&parent->rb_right == link ? list->next:list); } /* * The red-black tree where we try to find VA neighbors * before merging or inserting is empty, i.e. it means * there is no free vmap space. Normally it does not * happen but we handle this case anyway. */ return NULL; } ... static inline void __merge_or_add_vmap_area(struct vmap_area *va, struct rb_root *root, struct list_head *head) { ... /* * Get next node of VA to check if merging can be done. */ next = __get_va_next_sibling(parent, link); if (unlikely(next == NULL)) goto insert; ... } Agree with your point and comment. Thanks! -- Vlad Rezki