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 87868C19F2D for ; Wed, 10 Aug 2022 01:30:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 06D528E0002; Tue, 9 Aug 2022 21:30:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F38698E0001; Tue, 9 Aug 2022 21:30:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD8FB8E0002; Tue, 9 Aug 2022 21:30:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C84038E0001 for ; Tue, 9 Aug 2022 21:30:29 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 92AD916069D for ; Wed, 10 Aug 2022 01:30:29 +0000 (UTC) X-FDA: 79781952978.06.7DF8EB3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 994991C01AB for ; Wed, 10 Aug 2022 01:30:25 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8DE6D61259; Wed, 10 Aug 2022 01:30:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40D54C433D6; Wed, 10 Aug 2022 01:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1660095013; bh=h1Xe4kLj1fZVvhCfG/JILBgStIWuw0hoaqbRBEzMgYg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SAXDGcalYV4NL1NfK1zPnZDJI1TJTB5rtxKYu8NosaTL2DGD3C+Qw+3pzUxHmtOrU tb7l4QpOMDGve/O/fsSj38HuX8YENl3kWAeaEvchuGx0TrmDQxgig82SdeRuDdT1J1 ORVrgY/uJ10ezYCWeYjf1zc3HlPrpLhP5KAt8Lkk= Date: Tue, 9 Aug 2022 18:30:12 -0700 From: Andrew Morton To: Carlos Llamas Cc: Liam Howlett , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , syzbot , Ondrej Mosnacek , "syzkaller-bugs@googlegroups.com" , Minchan Kim , Christian Brauner , Greg Kroah-Hartman , Hridya Valsaraju , Joel Fernandes , Martijn Coenen , Suren Baghdasaryan , Todd Kjos , Matthew Wilcox , Arve =?ISO-8859-1?Q?Hj=F8nnev=E5g?= Subject: Re: [PATCH] binder_alloc: Add missing mmap_lock calls when using the VMA Message-Id: <20220809183012.ac2d52eb91eba55a12d3214a@linux-foundation.org> In-Reply-To: References: <20220809160618.1052539-1-Liam.Howlett@oracle.com> <20220809190211.ew4taam2lcomramw@revolver> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660095028; a=rsa-sha256; cv=none; b=1nwu4FiPKpXqvKJl+QQEZ6s61o/P3QXCim8+TY9ACk91W6AztYLBzYQ3MEOaXs/wgDInRK vLCbQlZNcMVh0n3ggkiBjLJEcXOHz2GIgfD4czkEJxeQDRpqZb1LTuh33Xt7dA0/WRmvYq 59QR218igdPQ4hjaf4KUUocbOXsWtIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660095028; 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=exlLwk9GO9CPrF3i7YA8BHB6gwnwt0kS+KWFz8qKA5s=; b=euadALsGmrKge39s3tkuKLFB8Cjmh3z7medznqZoZYSAsRw8H3yQegBQ5x7NUPcZrgbR5Q rMh10GmV55X+6Qo5RVn36kwLiygMMiGESsQwUg73ZRCyxSCQWQn4yT4N2ok5m9e46SloTO WD+PLSkf54trgeADqdPghxdmBMitA8k= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=SAXDGcal; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: sy8ejppw19fw1jpjrik575gho18k85p5 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 994991C01AB Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=SAXDGcal; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1660095025-618597 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, 9 Aug 2022 21:01:55 +0000 Carlos Llamas wrote: > On Tue, Aug 09, 2022 at 07:02:17PM +0000, Liam Howlett wrote: > > > > > > do we need to hold on to the lock while we loop through the pages here? > > > > I think we do? Holding this lock will ensure the pages don't go away, I > > believe (looking at mm/rmap.c comments on locking at the top)? > > > > In any case, this function is called from print_binder_proc_stats() > > which looks to be a debugfs/debugging call so I thought safer would be > > better than faster and with a potential race. > > The pages are protected by alloc->mutex, so you could immediately > release the mmap lock after binder_alloc_get_vma() call. I agree this > is a debugging call so it would be nice to reduce contention. I'll queue this patch for testing, shall update it if there's a v2.