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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1E7AC433EF for ; Tue, 25 Jan 2022 19:17:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37A986B007B; Tue, 25 Jan 2022 14:17:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 32A086B007D; Tue, 25 Jan 2022 14:17:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CACC6B0080; Tue, 25 Jan 2022 14:17:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 0ED0A6B007B for ; Tue, 25 Jan 2022 14:17:46 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BBAC792ECE for ; Tue, 25 Jan 2022 19:17:45 +0000 (UTC) X-FDA: 79069768890.23.31E9BFA Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf17.hostedemail.com (Postfix) with ESMTP id 6D7E940005 for ; Tue, 25 Jan 2022 19:17:45 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id p27so58747660lfa.1 for ; Tue, 25 Jan 2022 11:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wZzixtPsBwjSdlfmVlQxvw65IbQas2Gqlofz//xzbt8=; b=SoiX0MB1KR/dZ1i0RrY8wFpu4FCIw2nPsbRx8INbBLCr10ClG/5D8Y5MXxUSb6i5Vs LY1GRHnVw+WHTeQCuf/jN5A7Ftfs5V+r0qa2Z6wJ25pHpM30g6zwvfr7VcibvIq+6w5P Y7NqDfXCdQ/q86EmFQR2qYP0Oqu8sfEUPhFmxYG61M4svXTBtHEnGqvc9d+iG4Q5/mg7 aRILAfn33GP+HHRI4DFLT1voIKNhtENCcliuJxLC38Hlac2r4g6WahCQMYJycpS1RLwf NnKiclmqbb3knOVRKllMHjM23zGZ3fsArhcL+92vdHsQepZgsIPKot+hPPzXlOBpbhsb x7Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wZzixtPsBwjSdlfmVlQxvw65IbQas2Gqlofz//xzbt8=; b=t07B4Olr1M+U5KPCjUKt3aSl/1Ku9NSJGnYjeA2HpS1n1NGQfIQEtOLdSFPyV+MPQX lo6MiWcpLKwY6pZtO3InGaOBJcQPoXBpx38T36zJmR/WYSq6/w7LUgvJbBr/yYosaSGj ygknLKpS3yU74NOzIqp2RKpk0B5CV6+oxHSv5iAUjjt/xYrN8QRoRGugPlNX7siysYMN zkPC/5JHbyw0snfs4+OmfONDU5Pe7fmI2xY6fpkuaquibZ+FvOqxsBkd7kN4D4CFZwAK d9TOgM7PKlpUkLRYmaTSTAoNuyNDRy6oJewqDQnLl045w35f0/c5RjnpGyoLS8om6iZd Eb1Q== X-Gm-Message-State: AOAM533qT/z814wiwGtN34FllEXXiVMQ0xTfBqPFe2YuLtO+Qar9mkyG /NHuKQ8avR2jco0EQc89LC0= X-Google-Smtp-Source: ABdhPJz18O5o0EYwKWuRD2/VV9tPzNMOAquUWPZmqL7c3La+ZxSp2jwLApG25RYI/RNZg3Xq2Qd7yg== X-Received: by 2002:a05:6512:39c2:: with SMTP id k2mr5581182lfu.49.1643138263873; Tue, 25 Jan 2022 11:17:43 -0800 (PST) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id z23sm819001lfu.84.2022.01.25.11.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:17:42 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 25 Jan 2022 20:17:40 +0100 To: Matthew Wilcox Cc: Uladzislau Rezki , Andrew Morton , linux-mm@kvack.org, LKML , Christoph Hellwig , Nicholas Piggin , Oleksiy Avramchenko Subject: Re: [PATCH v2 1/1] mm/vmalloc: Move draining areas out of caller context Message-ID: References: <20220125163912.2809-1-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: nzg9f8fo97hndk8rjc6s1rea8cqjpz1a X-Rspam-User: nil Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SoiX0MB1; spf=pass (imf17.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.44 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 6D7E940005 X-HE-Tag: 1643138265-428837 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, Jan 25, 2022 at 06:46:35PM +0000, Matthew Wilcox wrote: > On Tue, Jan 25, 2022 at 06:12:48PM +0100, Uladzislau Rezki wrote: > > On Tue, Jan 25, 2022 at 04:50:14PM +0000, Matthew Wilcox wrote: > > > On Tue, Jan 25, 2022 at 05:39:12PM +0100, Uladzislau Rezki (Sony) wrote: > > > > @@ -1768,7 +1776,8 @@ static void free_vmap_area_noflush(struct vmap_area *va) > > > > > > > > /* After this point, we may free va at any time */ > > > > if (unlikely(nr_lazy > lazy_max_pages())) > > > > - try_purge_vmap_area_lazy(); > > > > + if (!atomic_xchg(&drain_vmap_work_in_progress, 1)) > > > > + schedule_work(&drain_vmap_work); > > > > } > > > > > > Is it necessary to have drain_vmap_work_in_progress? The documentation > > > says: > > > > > > * This puts a job in the kernel-global workqueue if it was not already > > > * queued and leaves it in the same position on the kernel-global > > > * workqueue otherwise. > > > > > > and the implementation seems to use test_and_set_bit() to ensure this > > > is true. > > > > > It checks pending state, if the work is in run-queue you can place it > > one more time. The motivation of having it is to prevent the drain work > > of being placed several times at once what i see on my stress testing. > > > > CPU_1: invokes vfree() -> queues the drain work -> TASK_RUNNING > > CPU_2: invokes vfree() -> queues the drain work one more time since it was not pending > > But why not unconditionally call schedule_work() here? > We can :) The question is do we agree that extra queuing will be kind of spurious? Because the CPU_1 will complete all cleanups once it is physically on CPU and others workers just bail out. We can disregard those spurious wake-ups for sure. If someone complains about it in the future we can think later then. Re-spin and do it unconditionally? I do not have a strong opinion about it. -- Vlad Rezki