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 1BA2FC433EF for ; Tue, 25 Jan 2022 17:12:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 602BF6B00B9; Tue, 25 Jan 2022 12:12:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B1C98D0001; Tue, 25 Jan 2022 12:12:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4525F6B00BB; Tue, 25 Jan 2022 12:12:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id 33B816B00B9 for ; Tue, 25 Jan 2022 12:12:56 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D8472951A9 for ; Tue, 25 Jan 2022 17:12:55 +0000 (UTC) X-FDA: 79069454310.17.3979739 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by imf03.hostedemail.com (Postfix) with ESMTP id A323620090 for ; Tue, 25 Jan 2022 17:12:53 +0000 (UTC) Received: by mail-lf1-f48.google.com with SMTP id b9so8984083lfq.6 for ; Tue, 25 Jan 2022 09:12:53 -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=7UoNr+FE7GC0nQ8z1tVChh4XpJW2PQJ2WwCVe19A6is=; b=S2Xsca/pBrSKIBu1XKkk91Xs6ui1f21MF3n7w3FTBVND1oL16KZrrPpJdcJhz7N8gq kNPz454MhzpkjAx5abKNt0qGL0SPSWK/V7A2IdmQoioVfo6k+QfsCUJNofdglfsLsuJe OG1POLzTyyAeU9x8rx1YqUgR/WwrpZa+m3ZMeR3L83MwNAOB3HYFBCJIbd4mRYVahCEF PkMSRPs3MDZDLLZkFnWeqyTSd8NGhoR2ryosiLv6PnnBDOu4INgjD/dlABbS3QP8Oznr qzuQTq8oEm9Sq+Ma43usJI2a3QEwKCkkxXZsEuHKCu+ToD2dFF9/2oVU3mtxmUiE3VoW CVhw== 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=7UoNr+FE7GC0nQ8z1tVChh4XpJW2PQJ2WwCVe19A6is=; b=hodNLnG99sAoeh4kmwAi3eVJk7x3YM0edOsf2n8EvhFYm9sMSgWsCdraeSF7ciaNIy +fQYubaEJRP70aeCzwfX/1mQifBaEvqwj8PiPsBtDfPBCpW0qKopsiQCAKQ5cfch42kf nlU4jeiAuOMG3i1veb+Z5LGsTpaCFE16jZEEoTCfFUJr20XgQCUe2Y0nJijlE9058fPp C01wHqZMPZtrthfY3JjofQjsm8ttxhR/tk61q+ifkcnkCHXV9mlQzaxXjN6CMSXfU0nF jRtcL0m3MYGeGLCineFwZ10yP7YH2145AmGedshnSdU9/gb9p14XHdiRBZQMBNVLoVMs iZvA== X-Gm-Message-State: AOAM533hif4XDpCPsfFe6vJ8kVFLqHP5ow1f7PsX7MUy2+z+5TnWpS7f ENHA2PH/DQB4Ta4BgL/8KUw= X-Google-Smtp-Source: ABdhPJx4+NuT/KQg6rH8VOKC0RxcPtnDegIVdCANBNAXvi3Iuq/FjmXDFFXH8gMZ2jDn8dNZ6IZcrA== X-Received: by 2002:a05:6512:39c6:: with SMTP id k6mr8279504lfu.193.1643130772056; Tue, 25 Jan 2022 09:12:52 -0800 (PST) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id n17sm741684lft.140.2022.01.25.09.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 09:12:51 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 25 Jan 2022 18:12:48 +0100 To: Matthew Wilcox Cc: "Uladzislau Rezki (Sony)" , 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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A323620090 X-Stat-Signature: a491ibbmxsm437ia9aycojpx691t56hh X-Rspam-User: nil Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="S2Xsca/p"; spf=pass (imf03.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.48 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1643130773-111792 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 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 ... Instead of drain_vmap_work_in_progress hack we can make use of work_busy() helper. The main concern with that was the comment around that function: /** * work_busy - test whether a work is currently pending or running * @work: the work to be tested * * Test whether @work is currently pending or running. There is no * synchronization around this function and the test result is * unreliable and only useful as advisory hints or for debugging. * * Return: * OR'd bitmask of WORK_BUSY_* bits. */ i am not sure how reliable this is. Thoughts? -- Vlad Rezki