Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4663124yba; Tue, 30 Apr 2019 02:12:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1GAdShIUGp48HOVkw0JEKvgvsHFQfXFIhVrpynWAQpJIYyiSOfRDtWWFGMqcLDBQpYiuC X-Received: by 2002:a63:5149:: with SMTP id r9mr49204752pgl.177.1556615553551; Tue, 30 Apr 2019 02:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556615553; cv=none; d=google.com; s=arc-20160816; b=WnmCnEM6TA5ZgcB9PtTtooL5jDGlVuWC2RykKSERSci9PW+mKenvSMDK2OYKdlRLZO 7dm77RDaNdJonTzkDK05owElRWlgsbyyyU8I2uImt404IGpdRo6xvbqCYpUwHTxUh1RL nN/WBryKSyY5nvtx9cz+TAywSORQ+m25IetoctPAOcziK6XPoTdvM/enYTt/36U8p/N3 9fQfLI8oI6G0gP3C3mV2swyk/9RTX5FXQCtQHDBFiNt2xorhAFAtI5hSKaLb5hEwyL6V QFgoEXtavZC9sJI48cDhvUb5YyWktFm0jz5j1W4iLVnoC3iBT0b6CJutVajvYdHXy5zJ veUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=FIsfZvgOHluTZXTIryj3lfd3dDN6/7zHtU2jtxJbAOk=; b=gNlVmxruOY0Cf95uccTwj1UwjG1JOvKSznIjV8uVGmJk9wij1CxL2kOLLSE/5ZPdp4 PCW8tQc65hNgRuQUtGDWmYq1yuWXSK8lbPia2LcUVkU4+vEzsCkmJZAiI0Vv2W8ObTLu 6nuhnkr3qRdp9kEiGRBMwbApxMUAGGbHxSo15t13OQrvPmnH0XYPtaQ8a8QCUvAHWObw ee7fn8U8W6bMpW7xgIKNOuC2340dI+buTiHnvKh+kg4rF1z300fc8vSV+0YGUVOxk04k xocl/s/3dg36yK2FfWQM29UD90s6I36IkTZ7tN1vUgMYwRSo5r5x7ltL+kSV18Ndmnzq i1HA== 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=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e15si36486090pfn.31.2019.04.30.02.12.18; Tue, 30 Apr 2019 02: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=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726832AbfD3JKH (ORCPT + 99 others); Tue, 30 Apr 2019 05:10:07 -0400 Received: from relay.sw.ru ([185.231.240.75]:38976 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726165AbfD3JKH (ORCPT ); Tue, 30 Apr 2019 05:10:07 -0400 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hLOlz-0007UE-CV; Tue, 30 Apr 2019 12:09:59 +0300 Subject: Re: [PATCH 1/3] mm: get_cmdline use arg_lock instead of mmap_sem To: =?UTF-8?Q?Michal_Koutn=c3=bd?= , gorcunov@gmail.com Cc: akpm@linux-foundation.org, arunks@codeaurora.org, brgl@bgdev.pl, geert+renesas@glider.be, ldufour@linux.ibm.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mguzik@redhat.com, mhocko@kernel.org, rppt@linux.ibm.com, vbabka@suse.cz References: <20190418182321.GJ3040@uranus.lan> <20190430081844.22597-1-mkoutny@suse.com> <20190430081844.22597-2-mkoutny@suse.com> From: Kirill Tkhai Message-ID: <4c79fb09-c310-4426-68f7-8b268100359a@virtuozzo.com> Date: Tue, 30 Apr 2019 12:09:57 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190430081844.22597-2-mkoutny@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30.04.2019 11:18, Michal Koutný wrote: > The commit a3b609ef9f8b ("proc read mm's {arg,env}_{start,end} with mmap > semaphore taken.") added synchronization of reading argument/environment > boundaries under mmap_sem. Later commit 88aa7cc688d4 ("mm: introduce > arg_lock to protect arg_start|end and env_start|end in mm_struct") > avoided the coarse use of mmap_sem in similar situations. > > get_cmdline can also use arg_lock instead of mmap_sem when it reads the > boundaries. > > Fixes: 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct") > Cc: Yang Shi > Cc: Mateusz Guzik > Signed-off-by: Michal Koutný > Signed-off-by: Laurent Dufour > --- > mm/util.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/util.c b/mm/util.c > index 43a2984bccaa..5cf0e84a0823 100644 > --- a/mm/util.c > +++ b/mm/util.c > @@ -758,12 +758,12 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen) > if (!mm->arg_end) > goto out_mm; /* Shh! No looking before we're done */ > > - down_read(&mm->mmap_sem); > + spin_lock(&mm->arg_lock); > arg_start = mm->arg_start; > arg_end = mm->arg_end; > env_start = mm->env_start; > env_end = mm->env_end; > - up_read(&mm->mmap_sem); > + spin_unlock(&mm->arg_lock); > > len = arg_end - arg_start; This looks OK for me. But speaking about existing code it's a secret for me, why we ignore arg_lock in binfmt code, e.g. in load_elf_binary().