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=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 CD015C4361B for ; Mon, 14 Dec 2020 15:05:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 26FB2225AB for ; Mon, 14 Dec 2020 15:05:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26FB2225AB 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 565936B006C; Mon, 14 Dec 2020 10:05:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 515F46B006E; Mon, 14 Dec 2020 10:05:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42A396B0070; Mon, 14 Dec 2020 10:05:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 2C8C56B006C for ; Mon, 14 Dec 2020 10:05:53 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DE319181AEF39 for ; Mon, 14 Dec 2020 15:05:52 +0000 (UTC) X-FDA: 77592212544.30.eggs81_480b01f2741b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id E85531801F0D2 for ; Mon, 14 Dec 2020 15:05:41 +0000 (UTC) X-HE-Tag: eggs81_480b01f2741b X-Filterd-Recvd-Size: 3450 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Dec 2020 15:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607958339; 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=ZsRXHORkSBohlUPPStBUsx3EB0JydpdD1grl8BL2x68=; b=FmmkXdvO3Q2W5gCpPm5ULN1IrrxL7NQISPAM+Zfe3D0P8mwUaSW9TDQNrPrANlOtCRQtmC xjPIGOSBdfj7ZXM5yNA0P14+2pMegqiKp9XMsOjI7vUDahBGJJY99kGjplF7DPu31gVs+w mM+vb8JFO2w4P71pYnh5cXlk1+nVmqg= 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-373-f8o2K-UnO_2B8JW3ohNe-w-1; Mon, 14 Dec 2020 10:05:34 -0500 X-MC-Unique: f8o2K-UnO_2B8JW3ohNe-w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB2CB800D53; Mon, 14 Dec 2020 15:05:32 +0000 (UTC) Received: from llong.remote.csb (ovpn-116-252.rdu2.redhat.com [10.10.116.252]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EC5E10023BF; Mon, 14 Dec 2020 15:05:29 +0000 (UTC) Subject: Re: [PATCH] mm/vmalloc: Fix unlock order in s_stop() To: David Hildenbrand , Andrew Morton , "Uladzislau Rezki (Sony)" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20201213180843.16938-1-longman@redhat.com> <4510fe4a-a4e1-32e6-4263-5aa66aaa7895@redhat.com> From: Waiman Long Organization: Red Hat Message-ID: <290d5967-9929-b0df-a3db-755c102f6599@redhat.com> Date: Mon, 14 Dec 2020 10:05:28 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <4510fe4a-a4e1-32e6-4263-5aa66aaa7895@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 12/14/20 4:39 AM, David Hildenbrand wrote: > 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. > Yes, it may not be technically a real bug fix. However, the order just doesn't look right. That is why I sent out a patch to address that. Cheers, Longman