Received: by 10.213.65.68 with SMTP id h4csp1910725imn; Sun, 1 Apr 2018 19:01:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/LpxNcTEJ/6w9J4yIqLwRb81EfSSZat8mHhFkLr/8ptC8TtRFpeuxNNrbqXUMgdNisSoxK X-Received: by 10.99.158.81 with SMTP id r17mr5183668pgo.348.1522634497568; Sun, 01 Apr 2018 19:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522634497; cv=none; d=google.com; s=arc-20160816; b=mV+RnFqVLtgVLb5vPa5V8IjuF/Buw8AlolD7XNipLuPqkzYRE4SFPVFvzWjq89HDmi hIlxzQHfaU1a6lz0Qco4hMB0ialHFIIrLUhuSQylAU2/LBSbKpHCU3+9V+/YqUQ8XKsv XNSV7pwTf5uca0QjH3x8VVB9TWGXUHrQL0gi0xFwzBOWqt3MplSWuQlRHRuOyBr0ngPu iIFp5C3mXMNNQ1xBI7eQnY3GzQLmPzUABcWTYm6pgKHFZycI0K4amCDKquK5dApGLhSj 2vA0VhmiYK3rhhO2zCnWlfyDcxmrQ7KPuwElYuodjhlgxevwuG6+WQmmQkRVK1NYPKWb hrrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=QqpgZlMj4tNWUFDEr1LQfnwxCrZP9meHKRvGCTju3lE=; b=QXXkTwzzASfGudZmNGxZ6v+Z3cqUlJnhG7V41Mk67m0a/0hiSKKbgoFcdsc8LZD1ul XhxVZ+l6ArDsvuiNREkZM7Lb3H2BV/YSAX5QdczIaO3WwG8bTANJndjITz1gIHD9UsTx bANaQYGywRMjEsGZPmcBB9YkSbKcBw55tCVXGc+kKbtJx+3240aYIAk/n2c4DUIVg9pt dOZVhgQR805+YTe6QPxZBB/F9mLBLJGKfC/Ib2sgyEE8yKoaXWvesla++FQwUE1/4zRd nqW0Zr01PNZjfM3INzWW1SaDUQ9L8UbrgDR3wau0eMhKSdMjtAMLqqQMF8DTxHlvkJwL zHCw== 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si9063707pgp.89.2018.04.01.19.01.23; Sun, 01 Apr 2018 19:01:37 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754138AbeDBB6h (ORCPT + 99 others); Sun, 1 Apr 2018 21:58:37 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:47422 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754036AbeDBB6g (ORCPT ); Sun, 1 Apr 2018 21:58:36 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07402;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0T-TpD53_1522634294; Received: from US-143344MP.local(mailfrom:yang.shi@linux.alibaba.com fp:73.158.237.84) by smtp.aliyun-inc.com(127.0.0.1); Mon, 02 Apr 2018 09:58:17 +0800 Subject: Re: [v2 PATCH] mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct To: Michal Hocko Cc: adobriyan@gmail.com, willy@infradead.org, mguzik@redhat.com, gorcunov@openvz.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1522088439-105930-1-git-send-email-yang.shi@linux.alibaba.com> <20180327062939.GV5652@dhcp22.suse.cz> From: Yang Shi Message-ID: Date: Sun, 1 Apr 2018 18:58:07 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180327062939.GV5652@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/26/18 11:29 PM, Michal Hocko wrote: > On Tue 27-03-18 02:20:39, Yang Shi wrote: > [...] > The patch looks reasonable to me. Maybe it would be better to be more > explicit about the purpose of the patch. As others noticed, this alone > wouldn't solve the mmap_sem contention issues. I _think_ that if you > were more explicit about the mmap_sem abuse it would trigger less > questions. > > I have just one more question. Now that you are touching this area, > would you be willing to remove the following ugliness? > >> diff --git a/kernel/sys.c b/kernel/sys.c >> index f2289de..17bddd2 100644 >> --- a/kernel/sys.c >> +++ b/kernel/sys.c >> @@ -1959,7 +1959,7 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data >> return error; >> } >> >> - down_write(&mm->mmap_sem); >> + down_read(&mm->mmap_sem); > Why do we need to hold mmap_sem here and call find_vma, when only > PR_SET_MM_ENV_END: is consuming it? I guess we can replace it wit the > new lock and take the mmap_sem only for PR_SET_MM_ENV_END. Sorry for taking a little bit longer to get back since I was traveling. I think all the stuff can be protected by the new arg_lock except mm->brk since arg_lock can't prevent from concurrent writing from sys_brk(). We may use arg_lock to protect everything else other than mm->brk. The complexity sounds acceptable. Of course, as Cyrill mentioned, he prefers to deprecating prctl_set_mm since C/R is the only user of it. We may wait until he is done? Thanks, Yang > > Thanks!