Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2439947ybl; Thu, 29 Aug 2019 08:12:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAqbCnxoqkVX7lSJnDGVWvOtivE6HtdnBf/Wt4u3LZP3r4IBTuffDiy1JhNRdHxyQSondj X-Received: by 2002:a17:90a:b884:: with SMTP id o4mr10336926pjr.52.1567091553169; Thu, 29 Aug 2019 08:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567091553; cv=none; d=google.com; s=arc-20160816; b=l6o6ZnSLXruGuB1F+vpkHJEnRS1MAY0FgxQTej9EMIR3H2PI6kyw/4MrI18wK9HykG 8diFZAazgxr2OD1l1NE7teZ7U8jWyczc9q5fUdBuW7ifKlpQkfs9HDCcy2a7VjfUgUcw 84WYLNuk9XyPvTQEeZ2sgmwqPCjcZgHwYXflCkTYdHVimOqWejcrNF92N5GyuhUJSJGg c2fMhaOTUayUcphZn61yXLBAgObVUVp3LHQ5T4hBWMiDkidbaSoB7I45B5tXedkx1jAQ HOoW4NdeldommwJMYhh1jQkmOv2RVeB6PLOG+vquHduf2ixaVnzpgQFe05hzFEW9Vvzv mgjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=XFoYeeuKJhvV8pvuLkcLy0edNhLRYjqPcfCB/siIS5w=; b=B5jRaXa9Yts88n7ILo6LO4Fa1eLtO5QY5uAI4rqk+BWSZCd0GHj7UqlrU+oAxPb8wj XpW9GHGkToPi7e2xM+uBs6dyTJV8IFj/iiCyVri2WRYdUpHrAvi5ubkQxSHTJsdtEkDH 5rEI5VCrUGT+NfxoSFEJCXknTg5iYVMA9ca5XC/y382ZNRKz/o/QEFbLBwiTakap5f0Q YGiVVX51yp2xxcGEDS2oqWpufV3h6nHVw5BHOY+uExnCIG5kdhdXqLryK3Z1g4Td8pnK Da+mwlNWYa0f2Cg0/Ys91oPtQ5sFZ9S5ZtVAVLZj1/siLp5nfBjW5zSWxfluwKrXXxFQ XSmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si2179420pls.183.2019.08.29.08.12.16; Thu, 29 Aug 2019 08:12:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727481AbfH2PK5 (ORCPT + 99 others); Thu, 29 Aug 2019 11:10:57 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:52396 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbfH2PK5 (ORCPT ); Thu, 29 Aug 2019 11:10:57 -0400 Received: from 162-237-133-238.lightspeed.rcsntx.sbcglobal.net ([162.237.133.238] helo=elm) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1i3M4d-0001RJ-7M; Thu, 29 Aug 2019 15:10:55 +0000 Date: Thu, 29 Aug 2019 10:10:52 -0500 From: Tyler Hicks To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Todd Kjos , Greg Kroah-Hartman , devel@driverdev.osuosl.org Subject: Re: [PATCH AUTOSEL 4.14 05/14] binder: take read mode of mmap_sem in binder_alloc_free_page() Message-ID: <20190829151052.GB27650@elm> References: <20190829105043.2508-1-sashal@kernel.org> <20190829105043.2508-5-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190829105043.2508-5-sashal@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Sasha! On 2019-08-29 06:50:34, Sasha Levin wrote: > From: Tyler Hicks > > [ Upstream commit 60d4885710836595192c42d3e04b27551d30ec91 ] > > Restore the behavior of locking mmap_sem for reading in > binder_alloc_free_page(), as was first done in commit 3013bf62b67a > ("binder: reduce mmap_sem write-side lock"). That change was > inadvertently reverted by commit 5cec2d2e5839 ("binder: fix race between > munmap() and direct reclaim"). > > In addition, change the name of the label for the error path to > accurately reflect that we're taking the lock for reading. > > Backporting note: This fix is only needed when *both* of the commits > mentioned above are applied. That's an unlikely situation since they > both landed during the development of v5.1 but only one of them is > targeted for stable. This patch isn't meant to be applied to 4.14 since commit 3013bf62b67a ("binder: reduce mmap_sem write-side lock") was never brought back to 4.14. My backporting note above isn't helpful for AUTOSEL purposes. Do you have a suggestion for what I could have done in the patch tags to convey that guidance to AUTOSEL? Tyler > > Fixes: 5cec2d2e5839 ("binder: fix race between munmap() and direct reclaim") > Signed-off-by: Tyler Hicks > Acked-by: Todd Kjos > Signed-off-by: Greg Kroah-Hartman > Signed-off-by: Sasha Levin > --- > drivers/android/binder_alloc.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c > index e0b0399ff7ec8..81c67459259ec 100644 > --- a/drivers/android/binder_alloc.c > +++ b/drivers/android/binder_alloc.c > @@ -949,8 +949,8 @@ enum lru_status binder_alloc_free_page(struct list_head *item, > mm = alloc->vma_vm_mm; > if (!mmget_not_zero(mm)) > goto err_mmget; > - if (!down_write_trylock(&mm->mmap_sem)) > - goto err_down_write_mmap_sem_failed; > + if (!down_read_trylock(&mm->mmap_sem)) > + goto err_down_read_mmap_sem_failed; > vma = binder_alloc_get_vma(alloc); > > list_lru_isolate(lru, item); > @@ -965,7 +965,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item, > > trace_binder_unmap_user_end(alloc, index); > } > - up_write(&mm->mmap_sem); > + up_read(&mm->mmap_sem); > mmput(mm); > > trace_binder_unmap_kernel_start(alloc, index); > @@ -980,7 +980,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item, > mutex_unlock(&alloc->mutex); > return LRU_REMOVED_RETRY; > > -err_down_write_mmap_sem_failed: > +err_down_read_mmap_sem_failed: > mmput_async(mm); > err_mmget: > err_page_already_freed: > -- > 2.20.1 >