Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3839424pxb; Tue, 17 Nov 2020 05:06:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjyfzizqZO/jeWYD6btjAIwFcOqtiZbwHggsmQh8jEoKvMTLjDuXsu2XqZQPhqWV8WZyvo X-Received: by 2002:a17:907:2175:: with SMTP id rl21mr20022369ejb.59.1605618416365; Tue, 17 Nov 2020 05:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605618416; cv=none; d=google.com; s=arc-20160816; b=oIZIz0ro0Bcx+BLa1xzt6m4Nfh9r8JoMuM9hevgcNgojsmr9my2JsaUewGcHKjFtJ+ eXeS01kRLQucv8BnnVI68knoeW7WdcYQjEhkUcAF3lPw+njrmPXHOfU3XHhmKJ4pmZC3 YrZZbvRuq6lsJCW+8xTS6vtjdZaPvoaZL7o9xPBlTO9r7LTo99WD7FMjUle7NeXWOOUp T2/UkqSPKod/mj+3QcyHL7Y+nIQe1Y88L7yE0PjSgbHYntvTC/TY5557KzL2S4Lao66f 7j63BT4GpcLHvpet10sSkeNWFuHFd1snRa/v7p254hOHc1Hvp1rQjLTVE6Js11ROLFb6 BZgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=lOoRt7gRUVygfU+Sl/VWrnk6H3xPmjMwBcvxXe+wyCQ=; b=aOXJliVJfelT5AX6k/iG03X6NWxv6zzUPwZRan/IuI4G6Hta/GuyORiCL43pPK5dM+ IJEe5DOSFlmwdW1AmgxR31fXQ9+pinELLypQxy6JHhr6OZ1xUohUGuRk4CfWQRCUambC Eb8MucXrkfaBaJIiWScEn3KOb+RKxCTWkDM8kv9K8kZBGIjdKWsj/w9YFu+8PIatj9WF tUn6incfMqxHS/FGoIL9Qwvdhs+JlfpRiHULRwSWOw0z9pWXVSfuYATSD3ZYdFYkV8YD +VpSj+07RQy5x0EbD8DEsBhyVXAR1Q5vkLlTcI9voKbOmyttkt24TmvXemHYZ93EOVhn QyNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZZSQqqcI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id bo5si14067177ejb.102.2020.11.17.05.06.30; Tue, 17 Nov 2020 05:06:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZZSQqqcI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728176AbgKQNEl (ORCPT + 99 others); Tue, 17 Nov 2020 08:04:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726035AbgKQNEl (ORCPT ); Tue, 17 Nov 2020 08:04:41 -0500 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0809BC0613CF for ; Tue, 17 Nov 2020 05:04:39 -0800 (PST) Received: by mail-lf1-x142.google.com with SMTP id a9so28969285lfh.2 for ; Tue, 17 Nov 2020 05:04:38 -0800 (PST) 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=lOoRt7gRUVygfU+Sl/VWrnk6H3xPmjMwBcvxXe+wyCQ=; b=ZZSQqqcITOCtDFjG/ylX0ox1zmLGFZefZpz8kipr3jXFFmLZ0QJXJ1nl5PYWGyry17 vkRHeSyzuWuQfi+7bZEIg44eUwT75uYcVjKPg0H46nErXw+DU/LCe9Pj7rMa4BNolqjY qJeaS3GN2KR9eExu1CJhGjwpkMKlFFOmXRllK/TFQYSCni4LsMkUbfg0KGLkpBm8mIcu 2Eq20stKp1j2r484tIRJ0waV7in3q2aa+/DGVylHWV7IjjDVaRq+64kkEnt2DmMR6j7M LMg29udOJu2QT+gXTXv8BMTptc2EGLf3TeIF+NCk5m88KNb0KQIplnHXPQHXnr3zZUAr jL/Q== 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=lOoRt7gRUVygfU+Sl/VWrnk6H3xPmjMwBcvxXe+wyCQ=; b=p0sKeuhhGyi51e/RM8RAYa6js6jgCtrKSe7RYnP7cNyq2gWAd4ZnH8kkf/sbfl6ouD 9cJSmazzxwbHqY/69onNaHsHUsQ+oTaa6V0op5/8RcxegdlLT/DeD5SeWN4rDS2Qd0i6 nZrUiGpUsfv98q+6H6pYSaQ1sMzUj62knWWtDY+11LUTHeJ9BWkOqmZN9gyHFCPdkNKO MV1Qh+yOHykrAfBgb+FiuJ/VA5yuS/S2Y/mgb5EMSrNowhZiXxaKp1Gb0SS+mUbbxz24 Q1q2nEipyQq1eubeUTATqPZwtzkeT1Ph+mVHjLHhK+7qFAWFsGLHQxgradoxd8B8jDZ/ Qx/A== X-Gm-Message-State: AOAM5337gB8XvEnFmAoVxXykRE7rfc049iX4owuXYougXCtbCxpC8ddX K+12fzAoKdQ3jQge3CbVMs4= X-Received: by 2002:a05:6512:210b:: with SMTP id q11mr1594356lfr.238.1605618277471; Tue, 17 Nov 2020 05:04:37 -0800 (PST) Received: from pc636 (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id t6sm2989482lfk.207.2020.11.17.05.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 05:04:36 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 17 Nov 2020 14:04:34 +0100 To: huang ying Cc: "Uladzislau Rezki (Sony)" , Andrew Morton , linux-mm@kvack.org, LKML , Hillf Danton , Michal Hocko , Matthew Wilcox , Oleksiy Avramchenko , Steven Rostedt Subject: Re: [PATCH 2/2] mm/vmalloc: rework the drain logic Message-ID: <20201117130434.GA10769@pc636> References: <20201116220033.1837-1-urezki@gmail.com> <20201116220033.1837-2-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 10:37:34AM +0800, huang ying wrote: > On Tue, Nov 17, 2020 at 6:00 AM Uladzislau Rezki (Sony) > wrote: > > > > A current "lazy drain" model suffers from at least two issues. > > > > First one is related to the unsorted list of vmap areas, thus > > in order to identify the [min:max] range of areas to be drained, > > it requires a full list scan. What is a time consuming if the > > list is too long. > > > > Second one and as a next step is about merging all fragments > > with a free space. What is also a time consuming because it > > has to iterate over entire list which holds outstanding lazy > > areas. > > > > See below the "preemptirqsoff" tracer that illustrates a high > > latency. It is ~24 676us. Our workloads like audio and video > > are effected by such long latency: > > This seems like a real problem. But I found there's long latency > avoidance mechanism in the loop in __purge_vmap_area_lazy() as > follows, > > if (atomic_long_read(&vmap_lazy_nr) < resched_threshold) > cond_resched_lock(&free_vmap_area_lock); > I have added that "resched threshold" because of on my tests i could simply hit out of memory, due to the fact that a drain work is not up to speed to process such long outstanding list of vmap areas. > > If it works properly, the latency problem can be solved. Can you > check whether this doesn't work for you? > We have that cond_resched_lock() in our products. The patch that is in question creates bigger vmap areas on early step(merge them), so the final structure becomes less fragmented, what speeds up a drain logic, thus reduces a preemption off time. Apart of that, high priority tasks like RT or DL which are users of the vmalloc()/vfree() can start draining process from its contexts, what is also a problem. In that sense, i think we need to make the vfree() call to be asynchronous, so latency sensitive tasks and others do not perform any draining from their contexts. -- Vlad Rezki