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 BA38FC43334 for ; Thu, 23 Jun 2022 18:04:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 350A08E0171; Thu, 23 Jun 2022 14:04:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3000A8E0144; Thu, 23 Jun 2022 14:04:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EEAF8E0171; Thu, 23 Jun 2022 14:04:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1218E8E0144 for ; Thu, 23 Jun 2022 14:04:31 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id D26918098B for ; Thu, 23 Jun 2022 18:04:30 +0000 (UTC) X-FDA: 79610275500.09.06004AF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id EB9611C0025 for ; Thu, 23 Jun 2022 18:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656007469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HuFxUR6BTCKmq3RBhsxlLVghh4qSMBYPTGysPk14N1Q=; b=StjD9XNQuEK7zqantzUuRbeaC4dyAS8ZbY8L67ILG5Nd3oNZCeHZSS31y9EQAoWk7t0ttY VB6MGq+rT8XMcgWGrCVzqQV8Vb3WRH6VactiLArRAQpu1Yxvf48Pgds4rLQgqDAiLDytbM ehQOj33uw9RV2UepcLnKNBtAtl1LqXY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-201-YrC2u1TuMBC5FUUJwd0YGw-1; Thu, 23 Jun 2022 14:04:25 -0400 X-MC-Unique: YrC2u1TuMBC5FUUJwd0YGw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4B3EB3806709; Thu, 23 Jun 2022 18:04:25 +0000 (UTC) Received: from [10.22.9.91] (unknown [10.22.9.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FC7F2166B29; Thu, 23 Jun 2022 18:04:24 +0000 (UTC) Message-ID: Date: Thu, 23 Jun 2022 14:04:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [Question] vmalloc latency in RT-Linux Content-Language: en-US To: Baoquan He , Zhipeng Shi Cc: linux-mm@kvack.org, linux-rt-users@vger.kernel.org, tglx@linutronix.de, shengjian.xu@horizon.ai, schspa@gmail.com, Sebastian Andrzej Siewior References: <20220621121547.GB37196@ubuntu20> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656007470; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HuFxUR6BTCKmq3RBhsxlLVghh4qSMBYPTGysPk14N1Q=; b=Qwvb4/KkeWZ8S5dfTxyOqIE2rNGrD6SQq7Z/4QEUpaZjd8n/x4/QX9r+yZqBBwVDIS1HFS m77uP1NblON8A2FHGjUYHHlaH0PW5e8MupUOnRiG6aPFrrkX5uMpq3VhM2E+f8HtLT9z8B YYJVs5ctpLXnK2scKoEXVafUCEMGobA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=StjD9XNQ; spf=none (imf21.hostedemail.com: domain of longman@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656007470; a=rsa-sha256; cv=none; b=sHGsJe83JXLm+ypiTdJ2LsQtQ3EMqsdgstUMKVvoeK8k/bovbUbj9z3+komdB1S6HaRDVV ZxDnnyJDYI5tsXbYVUyZId8Wqah58uI5PDvyUwzWkaFoal/DUm9eoguBe1ebJKoCGte3j5 iP1MQZ/Cpy3r/p/B/qVM5LFOZ2nbUUI= Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=StjD9XNQ; spf=none (imf21.hostedemail.com: domain of longman@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: beu7pezri7uyyomnwc61jdjwok63arf4 X-Rspamd-Queue-Id: EB9611C0025 X-HE-Tag: 1656007469-424735 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 6/23/22 06:51, Baoquan He wrote: > On 06/21/22 at 08:15pm, Zhipeng Shi wrote: >> I noticed in rt-linux, vmalloc has a large latency. This is because the >> free_vmap_area_lock is held for a long time in the function >> __purge_vmap_area_lazy. >> >> In non-RT-Linux, because the function spin_is_contended is well >> implemented, so there will be no such problem. >> >> But in RT-Linux, spin_is_contended simply returns 0. I don't understand >> why this function was implemented like this before, but in order to >> solve this problem, I thought of two ways. >> >> The first is to modify the spin_is_contended definition in spinlock_rt.h >> as shown below, but I'm not sure if the change has side-effects: >> >> -#define spin_is_contended(lock) (((void)(lock), 0)) >> +static inline int spin_is_contended(spinlock_t *lock) >> +{ >> + unsigned long *p = (unsigned long *) &lock->lock.owner; >> + >> + return (READ_ONCE(*p) & RT_MUTEX_HAS_WAITERS); >> +} >> >> The second is by reducing the number of lazy_max_pages, but it will lead >> to lower performance of vmalloc. > __purge_vmap_area_lazy() has cond_resched_lock() to reschedule and drop > the lock. From your saying, it's spin_is_contended() which is not > working well to make rescheduling happen during __purge_vmap_area_lazy() > handling. Then the fixing should be done in lock side. Sebastian had sent out patch last year to fix spin_is_contended(). https://lore.kernel.org/lkml/20210906143004.2259141-3-bigeasy@linutronix.de/ However, there is no follow-up after some discussion and the patch wasn't merged. Cheers, Longman