From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58378C2D0E4 for ; Tue, 17 Nov 2020 13:04:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ADCF62225B for ; Tue, 17 Nov 2020 13:04:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZZSQqqcI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADCF62225B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A83ED6B0036; Tue, 17 Nov 2020 08:04:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0D896B005D; Tue, 17 Nov 2020 08:04:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D4EA6B0068; Tue, 17 Nov 2020 08:04:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id 5C11A6B0036 for ; Tue, 17 Nov 2020 08:04:40 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 025A8180AD822 for ; Tue, 17 Nov 2020 13:04:40 +0000 (UTC) X-FDA: 77493929520.29.pan04_5d0566b27331 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id C06EB180868D5 for ; Tue, 17 Nov 2020 13:04:39 +0000 (UTC) X-HE-Tag: pan04_5d0566b27331 X-Filterd-Recvd-Size: 5479 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Nov 2020 13:04:39 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id u18so29937822lfd.9 for ; Tue, 17 Nov 2020 05:04:39 -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=l08kca4dr5T+lExpF3mp40Rzsuf3/RSeOwuFmWmHNBwKLQsuVY2ocq8Sj3f2qNcFwq oJ7vOWSGhErpE5SOilpfzCT+YzfyKwc0RPo6+wF4aRmg7h5VBoVLGlPeQQKMxbx7uvBC tgH2gZpscOjCQvgd6zFq/asX+um3L0ZDHPq9BypqtFilNfMIUElmSLCyik2c/aORDD06 aea5uhuoAQNSDCSTJjXaodCyh26+DNML/QDw2AFH/x0tucmcO6z2NDOFJ3u2hOaZLK6V QKSFrbxgCQsJ5exZZ6x1J5TlaNNRmdGWr3fM7Ymdz7qdOCutOZjuZuYnzy+7SuH/9AH6 eT2Q== X-Gm-Message-State: AOAM530bN233yo8grJFoAtMjxQlR4644SSZO9CeRrw+ojNREfglz0oDW Dh3mmJvGJuFerrM5TTGc6gA= X-Google-Smtp-Source: ABdhPJxGk98DUyyioKZA28nW7+rRaIXDNACiz7urpEtkaq6VVVMF4oMmiM58tbnMbl2hVm/FCLeAIQ== 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) 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: 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