From patchwork Mon May 27 09:38:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Uladzislau Rezki (Sony)" X-Patchwork-Id: 10962449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBBA776 for ; Mon, 27 May 2019 09:38:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC66528AA5 for ; Mon, 27 May 2019 09:38:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C06B528ACD; Mon, 27 May 2019 09:38:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D32228AA5 for ; Mon, 27 May 2019 09:38:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04E9A6B0266; Mon, 27 May 2019 05:38:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F1C856B026B; Mon, 27 May 2019 05:38:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6E0A6B026C; Mon, 27 May 2019 05:38:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by kanga.kvack.org (Postfix) with ESMTP id 7120C6B0266 for ; Mon, 27 May 2019 05:38:54 -0400 (EDT) Received: by mail-lj1-f197.google.com with SMTP id 205so3082429ljj.4 for ; Mon, 27 May 2019 02:38:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=fnFIhfm6w+x6vlcZglDCubHYA2sqJDEBTXH+zDoT54E=; b=n8K597XhN2znFW2cdkp1KRLkeESuDMMZ2saC3vgEGvJ3vKbq/gfhjpV7g9+bIxGYMy MhzqeD99gIPA1cRBcYGGmIj7VQTMl0jk3VNOxDLLy71dMnm3KhnGnGv4gh8+EyQs5QJe iMjOU3dOXQfu34+spBB9EMgEpEPBMZ6KseHolcRRARsXWKA0jjxpsoyGbWSSr11Vg0M0 2qjooF0DtqhWEU8PW1vcBEt3U2B/r4adh5QOFhE5ViqeXyek0UHSJ6SnGZpYqc0ZxVOL Vrts8T34qelNGxwMbP6CzkFfTbNr6+ttZ1mxdAM5LohjrpL8ToQ8HXpw4nDGnigQ20Zr umNw== X-Gm-Message-State: APjAAAXcheU8pgi7qiBfeQx0wATcdRiDAMNKj6uBkB6vDDqJODaqj7G8 3T176EAYBuJ63kWPX2/q2jPBTv1Y00XSh7SXXyRGFUqNyYQRn47/Q7imY77zvqh3iWUghAP98Du 8T9SkD1awVtniw3pjnUBFfytDPn6dYzr/oyBXO88uCNQWXJC7dEJqnJAOKLJzDk7/lw== X-Received: by 2002:a2e:864e:: with SMTP id i14mr28798430ljj.141.1558949933928; Mon, 27 May 2019 02:38:53 -0700 (PDT) X-Received: by 2002:a2e:864e:: with SMTP id i14mr28798383ljj.141.1558949932983; Mon, 27 May 2019 02:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558949932; cv=none; d=google.com; s=arc-20160816; b=tDK7EWRhp+CKOuBfheO3tVtE9151wsdksjFtnWB3U7vFQeRw+SWXJi2k94oym1Fs/f l8jZpSIk9pLv5Yfg/dnr00UzUoIAohYTosuA8T+fmGmaImwx1cs3QylQRJJ/W4UNKzBz neIbeK79v/21t/W6PQ93QNhF37JbZrgyX24ydXPZ2twj9+rgrKDvbmXVIw1O362AthrP CIAp3O8fTZKAxILETQuxzosccQDGh3PAkX4g179tVpvXMJYRbq9+Sshm5rvPHqLtB66q Xeb8vk4MFK1vqeYvidG8EaKf8BsymLVY99GUb0EHYt3djuJNwclwCNoaDnpkts+9YDTg 7v8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fnFIhfm6w+x6vlcZglDCubHYA2sqJDEBTXH+zDoT54E=; b=LRWvnccZD9LssBc7jBN6PjXO7erHWBVqnaalhau6Jdrc0QX2ePMcg33JRdnqGfy7pW cbVy/3vy9+RJl3bo2brCMv3R5XnYquCGxt0o2sBcZ5F8+WOnobGG2ToA5/87RTP+rGQ2 eRCSQbVCKXnIpWn/U6/Hu/N3LsSiI3JCH1njW/WnbBl3HRRwsJ01F53PVnpX7D4DDqeb bTy79QWfAKd1hv+rxmtl4ekh3zQYcBCrgCcxPv5UKhUVBDq1DNbDN0cB1s8XmRbBEF3V yd94zTUTfxyW2Zp/HCSGjLcLORXSE9tnDp4uLMHjlT4cUlHoonakrnt43cLQKXs9YezZ yMxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tb7K9MML; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c11sor4974656lja.9.2019.05.27.02.38.52 for (Google Transport Security); Mon, 27 May 2019 02:38:52 -0700 (PDT) Received-SPF: pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tb7K9MML; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fnFIhfm6w+x6vlcZglDCubHYA2sqJDEBTXH+zDoT54E=; b=Tb7K9MMLxMfT8Ruf4WhPnYDIGjoQlIJuk2rE0mwfrdgOa/ztIWbsgQRI00S7Iejm44 hO7Bn46pPdR249Rmcc1jZDG2trMR8cqjlK4Kv2xTAQqcJQQ82aP1b10pZZFz+CDc9qLj cfkr89AF+OJ6LHZd+GGhpFaEUIWiZVM4F3jXQlnztnDKPVcwLVyKw/7LYsO7FrOhnC1Y qYGeXOx6TkhbMI3bbxrw337HiydFA0nJ/+KrDcd6M7/w1gfyW0hw1SrPBC5bz5k9BJXx XRyhT06BSCeU8Jp0OAn+AU1ZNGNNX7c2oxxAz3E7mtf8G7P+cYWz44gNM+/OOh5Tw/u3 Hf9A== X-Google-Smtp-Source: APXvYqxqDucO+QSLHcUPvlIGziovBalve+hsDNrpg9l8JvuiiZP9nKTlMH0Z+oGIvB6vfIb/4Pv8Aw== X-Received: by 2002:a2e:8850:: with SMTP id z16mr16840496ljj.69.1558949932592; Mon, 27 May 2019 02:38:52 -0700 (PDT) Received: from pc636.semobile.internal ([37.139.158.167]) by smtp.gmail.com with ESMTPSA id z26sm2176293lfg.31.2019.05.27.02.38.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 02:38:51 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton , linux-mm@kvack.org Cc: Roman Gushchin , Uladzislau Rezki , Hillf Danton , Michal Hocko , Matthew Wilcox , LKML , Thomas Garnier , Oleksiy Avramchenko , Steven Rostedt , Joel Fernandes , Thomas Gleixner , Ingo Molnar , Tejun Heo Subject: [PATCH v3 1/4] mm/vmap: remove "node" argument Date: Mon, 27 May 2019 11:38:39 +0200 Message-Id: <20190527093842.10701-2-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190527093842.10701-1-urezki@gmail.com> References: <20190527093842.10701-1-urezki@gmail.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP Remove unused argument from the __alloc_vmap_area() function. Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Roman Gushchin --- mm/vmalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index c42872ed82ac..ea1b65fac599 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -985,7 +985,7 @@ adjust_va_to_fit_type(struct vmap_area *va, */ static __always_inline unsigned long __alloc_vmap_area(unsigned long size, unsigned long align, - unsigned long vstart, unsigned long vend, int node) + unsigned long vstart, unsigned long vend) { unsigned long nva_start_addr; struct vmap_area *va; @@ -1062,7 +1062,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, * If an allocation fails, the "vend" address is * returned. Therefore trigger the overflow path. */ - addr = __alloc_vmap_area(size, align, vstart, vend, node); + addr = __alloc_vmap_area(size, align, vstart, vend); if (unlikely(addr == vend)) goto overflow; From patchwork Mon May 27 09:38:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Uladzislau Rezki (Sony)" X-Patchwork-Id: 10962451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89C2A76 for ; Mon, 27 May 2019 09:39:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A50E28AA5 for ; Mon, 27 May 2019 09:39:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DEFD28ACD; Mon, 27 May 2019 09:39:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D59C328AA5 for ; Mon, 27 May 2019 09:38:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B767E6B026C; Mon, 27 May 2019 05:38:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A62626B026D; Mon, 27 May 2019 05:38:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83F206B026E; Mon, 27 May 2019 05:38:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id 149866B026C for ; Mon, 27 May 2019 05:38:56 -0400 (EDT) Received: by mail-lj1-f200.google.com with SMTP id y11so3071035ljc.20 for ; Mon, 27 May 2019 02:38:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=MSM6WbF67OdKB/w9seZTGzSuynUfhCF7zBIV2w+Az9Q=; b=Soclc60WuOAKTyvr07R1uukQ16ng1MqoLOuLruY1y84mRlykZzCZGbLqDaqxdX9dHT Z3UipjjWLXlVC6o7jdC7JmNIlj5kvA3K3xcGgzSVh3t4axW4RklgG5uPFqKuwZASfk6v ys3r+mzq+3k3plaQhURjN9KnDYoJUvqQ3Uft+CjN6hQ5VxrQ2//6x9a1oS/GZwTpfuil VCJYLH1up8z3xIL52+E8cW0j/er/e2fIteq1eoenl/ly/4RthwT8IB14DE+YEkFcatbL kZqPSO5o2vuTkZR9eD0fidK0PxNKEY91mrAINtssrR2ny2jZo/L2nsy8eKnwNuhxQCrJ 39yg== X-Gm-Message-State: APjAAAWUQCctnNdrmoyiAybERYurovf5EYQVJ/avvm/EhTrn4HxIp9An M5iCua+12CnvMiGwlLY4D0sRxJqUNcBVAkae/CphUYaJnBv0kRCj+5NEO2klkytalPc0ftU+PN/ 6Fo2WIWCU63bkErAUFJdF6kRs2bZnYwaF6uyl2WVULse69ONzwhhFpgMTg6VXLiLe6w== X-Received: by 2002:a2e:8041:: with SMTP id p1mr9990251ljg.121.1558949935539; Mon, 27 May 2019 02:38:55 -0700 (PDT) X-Received: by 2002:a2e:8041:: with SMTP id p1mr9990197ljg.121.1558949934245; Mon, 27 May 2019 02:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558949934; cv=none; d=google.com; s=arc-20160816; b=UyYeGu9WTX3BWKh4jpXjGj2oErQl/owZt0ptBYdEwyXOwvzDGduEvsV5tOpSfGWZXm ABAXqgjxcVo2P7Wdim7sZi8pWLcdYFQZ1d/252o40rwNgeGq66530utDNc1or3YR4iBP p2UaMcmOWBJ6/GStYfmtsZXGv57rdDULwvRZT7VNNmIkWbhpfTkAbqr8/4pbrLw86rLP k0pBKHVaZnTSxrSJzu3fQ364H28ZPz44E5JuG2DauaxPXTiiIdC+i24mDcMQzD3SjFF4 qBkTo79bvOEXa6SFcDIVT/mYbLsfWQGdMVJJBfWIVtYQwrIQ29V0yy13d/2qXE0aGW5V oHiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MSM6WbF67OdKB/w9seZTGzSuynUfhCF7zBIV2w+Az9Q=; b=nEADGjEEKVAMQWKD9AczqeV0biRYIpEDVsshk8hiR6GYdb/F/Gm5AZAXsRizVpHATQ WjEU1abW+GGwSFewsZd2v01crbxr2R/cgWOteJRfsvWXMvacTQsCGm6ZxVE/L9VP5EsL clOxGDQ486yTOtuHn8Lp+8t9j+ErdYwV8227j3YHHlqGgpTKxa3BJYwk7Zbh0qVidSYs ELjuXmYCpSp/+udbgMR0slC4tOnB20y0y7CNSMUmUF/NEr6mno0CE19rtpQXnCwx2f3a h7AohQvSux/svFvRS/shHTlwrXozGNDhpDD0lbu/hfgEQ2wHSvoxnH176+IHgydH2zb+ B/ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sUmGQPCg; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id k16sor1240008lfm.30.2019.05.27.02.38.54 for (Google Transport Security); Mon, 27 May 2019 02:38:54 -0700 (PDT) Received-SPF: pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sUmGQPCg; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MSM6WbF67OdKB/w9seZTGzSuynUfhCF7zBIV2w+Az9Q=; b=sUmGQPCg1h4G78WjpktomzL1vsZjD0vSyk4a/TMHRWTP028OvSlppVxZRdtKGtzAdE dylJ9B0jJSDE4NcUiWzqLubR3R3IS1TrLXMmlTpGoe8Qo7FKO7MmDhH9Nu7psaV6+gq4 hI1D22BOnCwUFc9siRF0Jyq/8y/Ujmz9NQtUKgTo/4yT+EiJE2Ai5NQaj385hImHrFMy I1BEQGZRmVHol66Bjz+NAC4ueF4Soqnx8L3y+Y8g6CwqNEJYL7ej4SKK6unwW2/17slz xuWVzqyjXSDEfPkHdHJLNbCb5A/XaaaOpimcUqBzhavLqVIsDrW8K7bkXeyMjwIAncPp 85xg== X-Google-Smtp-Source: APXvYqzERAbBtlp4Er6Lh4C9w2h4kNRVuBtp0mnWStcvdQ80Dpqy67L/LVB/6darmfplemsj1nipog== X-Received: by 2002:a19:7716:: with SMTP id s22mr2343486lfc.64.1558949933874; Mon, 27 May 2019 02:38:53 -0700 (PDT) Received: from pc636.semobile.internal ([37.139.158.167]) by smtp.gmail.com with ESMTPSA id z26sm2176293lfg.31.2019.05.27.02.38.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 02:38:53 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton , linux-mm@kvack.org Cc: Roman Gushchin , Uladzislau Rezki , Hillf Danton , Michal Hocko , Matthew Wilcox , LKML , Thomas Garnier , Oleksiy Avramchenko , Steven Rostedt , Joel Fernandes , Thomas Gleixner , Ingo Molnar , Tejun Heo Subject: [PATCH v3 2/4] mm/vmap: preload a CPU with one object for split purpose Date: Mon, 27 May 2019 11:38:40 +0200 Message-Id: <20190527093842.10701-3-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190527093842.10701-1-urezki@gmail.com> References: <20190527093842.10701-1-urezki@gmail.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP Refactor the NE_FIT_TYPE split case when it comes to an allocation of one extra object. We need it in order to build a remaining space. Introduce ne_fit_preload()/ne_fit_preload_end() functions for preloading one extra vmap_area object to ensure that we have it available when fit type is NE_FIT_TYPE. The preload is done per CPU in non-atomic context thus with GFP_KERNEL allocation masks. More permissive parameters can be beneficial for systems which are suffer from high memory pressure or low memory condition. Signed-off-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ea1b65fac599..b553047aa05b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -364,6 +364,13 @@ static LIST_HEAD(free_vmap_area_list); */ static struct rb_root free_vmap_area_root = RB_ROOT; +/* + * Preload a CPU with one object for "no edge" split case. The + * aim is to get rid of allocations from the atomic context, thus + * to use more permissive allocation masks. + */ +static DEFINE_PER_CPU(struct vmap_area *, ne_fit_preload_node); + static __always_inline unsigned long va_size(struct vmap_area *va) { @@ -950,9 +957,24 @@ adjust_va_to_fit_type(struct vmap_area *va, * L V NVA V R * |---|-------|---| */ - lva = kmem_cache_alloc(vmap_area_cachep, GFP_NOWAIT); - if (unlikely(!lva)) - return -1; + lva = __this_cpu_xchg(ne_fit_preload_node, NULL); + if (unlikely(!lva)) { + /* + * For percpu allocator we do not do any pre-allocation + * and leave it as it is. The reason is it most likely + * never ends up with NE_FIT_TYPE splitting. In case of + * percpu allocations offsets and sizes are aligned to + * fixed align request, i.e. RE_FIT_TYPE and FL_FIT_TYPE + * are its main fitting cases. + * + * There are a few exceptions though, as an example it is + * a first allocation (early boot up) when we have "one" + * big free space that has to be split. + */ + lva = kmem_cache_alloc(vmap_area_cachep, GFP_NOWAIT); + if (!lva) + return -1; + } /* * Build the remainder. @@ -1023,6 +1045,48 @@ __alloc_vmap_area(unsigned long size, unsigned long align, } /* + * Preload this CPU with one extra vmap_area object to ensure + * that we have it available when fit type of free area is + * NE_FIT_TYPE. + * + * The preload is done in non-atomic context, thus it allows us + * to use more permissive allocation masks to be more stable under + * low memory condition and high memory pressure. + * + * If success it returns 1 with preemption disabled. In case + * of error 0 is returned with preemption not disabled. Note it + * has to be paired with ne_fit_preload_end(). + */ +static int +ne_fit_preload(int nid) +{ + preempt_disable(); + + if (!__this_cpu_read(ne_fit_preload_node)) { + struct vmap_area *node; + + preempt_enable(); + node = kmem_cache_alloc_node(vmap_area_cachep, GFP_KERNEL, nid); + if (node == NULL) + return 0; + + preempt_disable(); + + if (__this_cpu_cmpxchg(ne_fit_preload_node, NULL, node)) + kmem_cache_free(vmap_area_cachep, node); + } + + return 1; +} + +static void +ne_fit_preload_end(int preloaded) +{ + if (preloaded) + preempt_enable(); +} + +/* * Allocate a region of KVA of the specified size and alignment, within the * vstart and vend. */ @@ -1034,6 +1098,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, struct vmap_area *va; unsigned long addr; int purged = 0; + int preloaded; BUG_ON(!size); BUG_ON(offset_in_page(size)); @@ -1056,6 +1121,12 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask & GFP_RECLAIM_MASK); retry: + /* + * Even if it fails we do not really care about that. + * Just proceed as it is. "overflow" path will refill + * the cache we allocate from. + */ + preloaded = ne_fit_preload(node); spin_lock(&vmap_area_lock); /* @@ -1063,6 +1134,8 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, * returned. Therefore trigger the overflow path. */ addr = __alloc_vmap_area(size, align, vstart, vend); + ne_fit_preload_end(preloaded); + if (unlikely(addr == vend)) goto overflow; From patchwork Mon May 27 09:38:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Uladzislau Rezki (Sony)" X-Patchwork-Id: 10962453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D988015A6 for ; Mon, 27 May 2019 09:39:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FDD028B5C for ; Mon, 27 May 2019 09:39:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8926B28B50; Mon, 27 May 2019 09:39:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE0D228B2C for ; Mon, 27 May 2019 09:39:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 113F06B026D; Mon, 27 May 2019 05:38:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 09CDF6B026F; Mon, 27 May 2019 05:38:59 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E59096B0270; Mon, 27 May 2019 05:38:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by kanga.kvack.org (Postfix) with ESMTP id 769B66B026D for ; Mon, 27 May 2019 05:38:58 -0400 (EDT) Received: by mail-lj1-f198.google.com with SMTP id q20so3085580ljg.0 for ; Mon, 27 May 2019 02:38:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=5tFxW9hH4KTKWLbD5PL7NocPZCk93KxY6ol7ln5ws1s=; b=NeheIFffpUsh4sNpadK7rR0dZpy92rnEwsWq4FTBY0eTJbQlTdcgPBtYZog9OCgjpN 6uGeWQOyebmtUyM3OuZJqtv4spq9ahr9JfXIQV/fYBSk9JcWPr039iGALLk+/MefgZzb iRLyy4ACLIve9UuiNGDw1P2eMjMbUccv/MNg714SzYK2UFrqpF7DsF4X9YbUzJMNiSEu mqLAt9I43+k5E2b/7P1J8uwxfovH2WhqVPdRc56zuBKDNaB9lNwjzxh6zxMGdY/dV6M3 W/8bSkV1u8GtxYnqwrv+xFMjGtBThjlfkykhma/fEAbbKHWGPtso8IDcvell7thY/yLm rEqA== X-Gm-Message-State: APjAAAXojJzm1DrpWYjPCnIikGCDKQL3USo9E2CjLIaAqsQiv67lcg/m JswfM1dru566W186Mv5YeN9mEIAbdVBShqHTrkgh4UmOXa6/HX255qFNFyvHdAZGCHQCtba51oD nDssXWtEQLu1AEo4frxlHzLW6JT+LSIu1L3GCbg2XTOmgtFYV9vLFR7AlVgN8HOOd8Q== X-Received: by 2002:a2e:9185:: with SMTP id f5mr30990585ljg.51.1558949937879; Mon, 27 May 2019 02:38:57 -0700 (PDT) X-Received: by 2002:a2e:9185:: with SMTP id f5mr30990540ljg.51.1558949936822; Mon, 27 May 2019 02:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558949936; cv=none; d=google.com; s=arc-20160816; b=mTIpEFBb0FxQhHUdiKEU+BFJFTfun12KenLed/D9SuaoaZm0lc6TFSiwIV4/mN+KHy wIaalfs7LSwzAmp0iJR/pkfhrGATtueInNs3V2ZpYsYTBRRNDVH3xrd4jqPiXUf24baT vjlqkBANhehQMnokMhpc0R28iTzSlsShddUfq0SxXQR1Lmz17ECnXbpaEaNId+r7x5UI Ykbs2e4zjSZ9IH4TrGOdlGgbSS54EI7dFRsEuhFALo+fqE03YB2KLDoydrkKmP2A4lvH RAKB6ol5qcNTJTU7iLyIbWlUMHooZ9d579AWaftIsbpmk+xgbqZ/AoXJ4azKG6UpZcfh usRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5tFxW9hH4KTKWLbD5PL7NocPZCk93KxY6ol7ln5ws1s=; b=l2LFtx5oZttRlRshdMOvmmL+WnkVIsBE77EYqaDvZ5gXyvy45hkGbfZ/YK4JLjcRyF /z4unNX8Fjmfm63zQ3DGLsjC55htkJQaWVmum/WMITkheCsQqUBbx94ylofJqiCHzBkd zmIh0c8jlq8QMBCo8/XGREQf5hvXvQxqDqm8rl5LDjAh2PeEO35t3HJMjJ8tz5GxMSKS TPIcIAKGHUa8bfgJx/mzRcuvgUmRgIGwyxhpjofeJ22zNpL+B/Y1WfKeQ1ZHbQXRGmBJ 8+j+yOeoU0NFFi8VxWmzGzrQCkjfDvG3krDuPdYKqwVndbBEAIGlqsAc/PMZBs6G4YU5 Etpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WdyDohT7; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x5sor2555270lfn.7.2019.05.27.02.38.56 for (Google Transport Security); Mon, 27 May 2019 02:38:56 -0700 (PDT) Received-SPF: pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WdyDohT7; spf=pass (google.com: domain of urezki@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5tFxW9hH4KTKWLbD5PL7NocPZCk93KxY6ol7ln5ws1s=; b=WdyDohT79RWv5sQw8j/CoiyAF1ieXhBzh55F/UbajT9jF/0uJ67nJC3KNnHTUPoI0T oUBP1DChU3kD4+oixvGJZjalRgEuupfxfw3tAciwmhJ8azlHnw/9zdY211g0HetUZqHo pcLoUQjOziPwn7lefVncMQD2ZdI0BPz9lVodeDp4CHJnFXoNRL5DLmsx9CbYtKPcw5No UCR/uvKE8YK6JKhvoExYF/ggb0izBa8VIDKiBvqNTs5o+yZ8G4Hrb4BkQtKx1Z4I6Pvb 0wCCaGD8KZvWTFTFFm9Z0/PQLWWVEWN+7T6Eg+/RaX3QawT2c0YbBBzBtdNCU4JatZ7j wZ9A== X-Google-Smtp-Source: APXvYqywlNbALD5TT5l11okB4ZaZ9LJNYUAYl35+RlPAv4hvj0NbaW0wQ0+uLocyyjJWapoGw3TE1w== X-Received: by 2002:ac2:5324:: with SMTP id f4mr5086344lfh.156.1558949936459; Mon, 27 May 2019 02:38:56 -0700 (PDT) Received: from pc636.semobile.internal ([37.139.158.167]) by smtp.gmail.com with ESMTPSA id z26sm2176293lfg.31.2019.05.27.02.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 02:38:55 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Andrew Morton , linux-mm@kvack.org Cc: Roman Gushchin , Uladzislau Rezki , Hillf Danton , Michal Hocko , Matthew Wilcox , LKML , Thomas Garnier , Oleksiy Avramchenko , Steven Rostedt , Joel Fernandes , Thomas Gleixner , Ingo Molnar , Tejun Heo Subject: [PATCH v3 4/4] mm/vmap: move BUG_ON() check to the unlink_va() Date: Mon, 27 May 2019 11:38:42 +0200 Message-Id: <20190527093842.10701-5-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190527093842.10701-1-urezki@gmail.com> References: <20190527093842.10701-1-urezki@gmail.com> 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: X-Virus-Scanned: ClamAV using ClamSMTP Move the BUG_ON()/RB_EMPTY_NODE() check under unlink_va() function, it means if an empty node gets freed it is a BUG thus is considered as faulty behaviour. Signed-off-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 371aba9a4bf1..340959b81228 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -533,20 +533,16 @@ link_va(struct vmap_area *va, struct rb_root *root, static __always_inline void unlink_va(struct vmap_area *va, struct rb_root *root) { - /* - * During merging a VA node can be empty, therefore - * not linked with the tree nor list. Just check it. - */ - if (!RB_EMPTY_NODE(&va->rb_node)) { - if (root == &free_vmap_area_root) - rb_erase_augmented(&va->rb_node, - root, &free_vmap_area_rb_augment_cb); - else - rb_erase(&va->rb_node, root); + BUG_ON(RB_EMPTY_NODE(&va->rb_node)); - list_del(&va->list); - RB_CLEAR_NODE(&va->rb_node); - } + if (root == &free_vmap_area_root) + rb_erase_augmented(&va->rb_node, + root, &free_vmap_area_rb_augment_cb); + else + rb_erase(&va->rb_node, root); + + list_del(&va->list); + RB_CLEAR_NODE(&va->rb_node); } #if DEBUG_AUGMENT_PROPAGATE_CHECK @@ -1187,8 +1183,6 @@ EXPORT_SYMBOL_GPL(unregister_vmap_purge_notifier); static void __free_vmap_area(struct vmap_area *va) { - BUG_ON(RB_EMPTY_NODE(&va->rb_node)); - /* * Remove from the busy tree/list. */