From patchwork Fri Oct 19 17:35:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 10649915 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 3204B109C for ; Fri, 19 Oct 2018 17:35:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 186E428497 for ; Fri, 19 Oct 2018 17:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C9092849D; Fri, 19 Oct 2018 17:35:59 +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 9B5ED28497 for ; Fri, 19 Oct 2018 17:35:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 829BF6B0008; Fri, 19 Oct 2018 13:35:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7D96A6B000C; Fri, 19 Oct 2018 13:35: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 6C8EF6B000D; Fri, 19 Oct 2018 13:35:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by kanga.kvack.org (Postfix) with ESMTP id F14016B0008 for ; Fri, 19 Oct 2018 13:35:55 -0400 (EDT) Received: by mail-lf1-f72.google.com with SMTP id m3-v6so795123lfh.14 for ; Fri, 19 Oct 2018 10:35:55 -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=QOpxQtsqnZO1O69woFc9jT6MsNTDcWqgsVf/VQ7puy8=; b=OHSNCOV8wyQrpldiGSm0ztJiVk4/sI02iWHUwWvPVOyGptCtuXAi8RlXIK9+FLM3Aa 4aTjtVKTabCjxsxYsYJFjgsDucGrA0g///SdZyJhYqPU0MmmzS3srPHXYQgXQtzOns75 sOex7d0vLnIfBQdF2zsYmCscUafUGL+Foy7j100yqNHkMy6+BGP/UY4M3NlDPrtH2zxQ ypugf01WghTiKST0Kv2c3wdmN5MqmvQ56aOgnGPExf21RH/QM6SbgZUKg8MJ7z3wfDPq Iicx11Mk+vpGZztjiBRjOxYBwYCCkpdOp+CS88vh5RIisVK1Fwl0DKDdrQvmz3HM0+Yp khBA== X-Gm-Message-State: ABuFfogtXdZrG85s7DkGlWhlQq/gkSDzAQZvM+Yq0XdSTD9qIhMjkKpP /1QwSnchOAf9V6RqFQo1C7S7cO2v4857g50JIWbACA3snOWlwG/vsCuhCVSFTkcCFBF6pNkT1vB PVQi9nIjLlyiZPj+BQ/4DfHe0yIqrQlvlQNH3DKHooiq928Wt7IQAcgwh9nnGykUT733Ogjw4gn LBfHnRwvRNnnB/9g1LsManJuHIHZxd2x/oiJwRg8Wjd2t+5+8gNRorFKUyuwEi42JM1DG+pbAhH H2vNZbb/vl/6ol65FJJGHFrIYZfN6Gn/4M/Hwwfg9Yu3647z0vDZtoMNZK1eM3s4tAgUZcz30WP YI8T5eqYnQWLbrAa4uZLliqOqrDLsgtKIaQEDofAVfulGDM2W6BkqozndiU6FP8Oqh47kddEJFi + X-Received: by 2002:a19:ec0a:: with SMTP id b10-v6mr3846817lfa.65.1539970555031; Fri, 19 Oct 2018 10:35:55 -0700 (PDT) X-Received: by 2002:a19:ec0a:: with SMTP id b10-v6mr3846780lfa.65.1539970553880; Fri, 19 Oct 2018 10:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539970553; cv=none; d=google.com; s=arc-20160816; b=GLHoiLfJZdbpETjRsVsRgvMGKyW6lHUDkJSggpyfXlIO/QDs65WLuX1sDpHDnr70mz TtbQ3YmVLyZDU3G97JPhPAuY0hOR8VyG8JJaCfzFXHHMxzIjCoawPoRANWp9/J0le3qZ F0b0HddRUk8IEVwy00EVUnNZJ8Ic7JaR6OaYrFSotH3McBh/Fej1CzOWrRMmZ8yOjBLL bZ7RUVqe9xEGseHo+uJ7fENS3IAoGQuo7h1Ej6+51ykLAO8zMvjScf5KAa0t2fYeCQ/z 6dpw9+ucrtV7g68UPVS8UZ8k7vZD+ggzNB8m/qgJnYMTLsGmTBB8WRatXpOxXu3nDo+H oDqA== 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=QOpxQtsqnZO1O69woFc9jT6MsNTDcWqgsVf/VQ7puy8=; b=KVy8y3jyBO1Gsh7OW+C7kZXIw0jpLPMt49HMRgUD0l4BuIyre9sSFx6VXwPJ2VQ96C cKpZXnblq49OYMbG61OCYbHuCcavqljjbP7kyPeJyuq9V+oay7nW4Wsd3fBPvx7jLAfv edHKPZhUE0zrkybtOIMdKO1kn1G/kK4KAv0EenuZcxFsMfJSVGmMcQpkt+VaxHycOI9R UntCk7TWTKDjH7hnMGeey7yGZWsaYvoQZlKC4DJ06bo2IzXVm0wUVLq6SsDo6bW89IuD RXCk7UyCE3T6LPGPhKC62EnYqd8BaR+dSqDmlVIpFPMNDbchyndTf7N4hIz/s18oUE2m m46g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=syXSz+ry; 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 n24-v6sor7822936lfe.33.2018.10.19.10.35.53 for (Google Transport Security); Fri, 19 Oct 2018 10:35:53 -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=syXSz+ry; 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=QOpxQtsqnZO1O69woFc9jT6MsNTDcWqgsVf/VQ7puy8=; b=syXSz+rynUT0XXnSrP7QxmpOFvRr5Bfr0xP2NEUQePfz5z37UIDck093aaGr+Jxa4v EIInTHwHm0Q1NDl5tr94Fdjbza1caupFFHFKQVtbRprJ360q4FOBCZ13lGxR4Zf+HMxQ 094PnyXuCxKdPliwGRChjlwkjH/W/vP9duBjC07du/+d5V8+x2QdLY3kZaPjdshVJdVP mh7t5Ai8b+R+dVx7nyy1No4zBKV5LFDhL/DjNTVsa9XiKP8BHHkRrRYw72bQ2wMQIHVv bGpn8T5tGgIOlqUQy7B5X1gv9wggtCiGwjIPj9TcxxaN8O1vYv1Sexy5i8ne01YMXcxG VupA== X-Google-Smtp-Source: ACcGV61jzkETd02239M3JQrg7GcoPJDUVxeCvyghNY325cP/LpZXE8bIG+qEVdYd9SXYWUownIJSJg== X-Received: by 2002:a19:a501:: with SMTP id o1-v6mr3480817lfe.41.1539970553327; Fri, 19 Oct 2018 10:35:53 -0700 (PDT) Received: from pc636.semobile.internal ([37.139.158.167]) by smtp.gmail.com with ESMTPSA id k9-v6sm5531530lje.51.2018.10.19.10.35.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 10:35:52 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: Matthew Wilcox , Andrew Morton , linux-mm@kvack.org Cc: LKML , Michal Hocko , Thomas Garnier , Oleksiy Avramchenko , Steven Rostedt , Joel Fernandes , Thomas Gleixner , Ingo Molnar , Tejun Heo , "Uladzislau Rezki (Sony)" Subject: [RFC PATCH 2/2] mm: add priority threshold to __purge_vmap_area_lazy() Date: Fri, 19 Oct 2018 19:35:38 +0200 Message-Id: <20181019173538.590-3-urezki@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181019173538.590-1-urezki@gmail.com> References: <20181019173538.590-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 commit 763b218ddfaf ("mm: add preempt points into __purge_vmap_area_lazy()") introduced some preempt points, one of those is making an allocation more prioritized. Prioritizing an allocation over freeing does not work well all the time, i.e. it should be rather a compromise. 1) Number of lazy pages directly influence on busy list length thus on operations like: allocation, lookup, unmap, remove, etc. 2) Under heavy simultaneous allocations/releases there may be a situation when memory usage grows too fast hitting out_of_memory -> panic. Establish a threshold passing which the freeing path is prioritized over allocation creating a balance between both. Signed-off-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index a7f257540a05..bbafcff6632b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1124,23 +1124,23 @@ static bool __purge_vmap_area_lazy(unsigned long start, unsigned long end) struct llist_node *valist; struct vmap_area *va; struct vmap_area *n_va; - bool do_free = false; + int resched_threshold; lockdep_assert_held(&vmap_purge_lock); valist = llist_del_all(&vmap_purge_list); + if (unlikely(valist == NULL)) + return false; + llist_for_each_entry(va, valist, purge_list) { if (va->va_start < start) start = va->va_start; if (va->va_end > end) end = va->va_end; - do_free = true; } - if (!do_free) - return false; - flush_tlb_kernel_range(start, end); + resched_threshold = (int) lazy_max_pages() << 1; spin_lock(&vmap_area_lock); llist_for_each_entry_safe(va, n_va, valist, purge_list) { @@ -1148,7 +1148,9 @@ static bool __purge_vmap_area_lazy(unsigned long start, unsigned long end) __free_vmap_area(va); atomic_sub(nr, &vmap_lazy_nr); - cond_resched_lock(&vmap_area_lock); + + if (atomic_read(&vmap_lazy_nr) < resched_threshold) + cond_resched_lock(&vmap_area_lock); } spin_unlock(&vmap_area_lock); return true;