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=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 53D87C4361B for ; Mon, 14 Dec 2020 09:39:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB7AA22B3F for ; Mon, 14 Dec 2020 09:39:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB7AA22B3F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 414566B0036; Mon, 14 Dec 2020 04:39:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C4BD6B005C; Mon, 14 Dec 2020 04:39:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DB586B005D; Mon, 14 Dec 2020 04:39:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id 17B286B0036 for ; Mon, 14 Dec 2020 04:39:44 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DE7FC1804161C for ; Mon, 14 Dec 2020 09:39:43 +0000 (UTC) X-FDA: 77591390646.30.head07_50060ff27419 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id BF53A180B3AB8 for ; Mon, 14 Dec 2020 09:39:43 +0000 (UTC) X-HE-Tag: head07_50060ff27419 X-Filterd-Recvd-Size: 3964 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Dec 2020 09:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607938782; 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=rxgxALgr4gUxLQSj9hCVOirpc3EUlBsOv2Udfb4doVE=; b=U8dvRIHCGz4kucaaR2z2+tQACHdIVQZjolc+1L/DcGT/jrZKyR09nhaG93sdtKbT6p1g57 l00mnb9zYvfFwd06ti8OUR5kC6OkqStOiHPVNVXXcLxNBDsne+ppPucpB5AN3b+9FFF+9+ ohm11bhaLWnXXTBrSYAcTKuOgzGYsNg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-66-KHn_iei_Oi-Jyst3LyhNXA-1; Mon, 14 Dec 2020 04:39:40 -0500 X-MC-Unique: KHn_iei_Oi-Jyst3LyhNXA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB3CC800D53; Mon, 14 Dec 2020 09:39:38 +0000 (UTC) Received: from [10.36.114.184] (ovpn-114-184.ams2.redhat.com [10.36.114.184]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0094D5D9D0; Mon, 14 Dec 2020 09:39:33 +0000 (UTC) Subject: Re: [PATCH] mm/vmalloc: Fix unlock order in s_stop() To: Waiman Long , Andrew Morton , "Uladzislau Rezki (Sony)" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20201213180843.16938-1-longman@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <4510fe4a-a4e1-32e6-4263-5aa66aaa7895@redhat.com> Date: Mon, 14 Dec 2020 10:39:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201213180843.16938-1-longman@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 13.12.20 19:08, Waiman Long wrote: > When multiple locks are acquired, they should be released in reverse > order. For s_start() and s_stop() in mm/vmalloc.c, that is not the > case. > > s_start: mutex_lock(&vmap_purge_lock); spin_lock(&vmap_area_lock); > s_stop : mutex_unlock(&vmap_purge_lock); spin_unlock(&vmap_area_lock); > > This unlock sequence, though allowed, is not optimal. If a waiter is > present, mutex_unlock() will need to go through the slowpath of waking > up the waiter with preemption disabled. Fix that by releasing the > spinlock first before the mutex. > > Fixes: e36176be1c39 ("mm/vmalloc: rework vmap_area_lock") I'm not sure if this classifies as "Fixes". As you correctly state "is not optimal". But yeah, releasing a spinlock after releasing a mutex looks weird already. > Signed-off-by: Waiman Long > --- > mm/vmalloc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 6ae491a8b210..75913f685c71 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -3448,11 +3448,11 @@ static void *s_next(struct seq_file *m, void *p, loff_t *pos) > } > > static void s_stop(struct seq_file *m, void *p) > - __releases(&vmap_purge_lock) > __releases(&vmap_area_lock) > + __releases(&vmap_purge_lock) > { > - mutex_unlock(&vmap_purge_lock); > spin_unlock(&vmap_area_lock); > + mutex_unlock(&vmap_purge_lock); > } > > static void show_numa_info(struct seq_file *m, struct vm_struct *v) > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb