Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4623909yba; Tue, 30 Apr 2019 01:20:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzV+txttNnoYrfBa27LZMnRA6L8DfIdni79HQnscUGusoAxiUNQPVM8VWCTjyqZoKJpjQsT X-Received: by 2002:a17:902:be09:: with SMTP id r9mr68182649pls.215.1556612439203; Tue, 30 Apr 2019 01:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556612439; cv=none; d=google.com; s=arc-20160816; b=Q9DNe5HUa/BWPliSR5pJUuZXdmQ48EbaT37oNfwPIKaXeCaIqjSOrVQsiz+QCQRroV Hz4YPaDktny4DbnxSibZ9MysXGFy8EhmGTQHeKaNUKq7ILVryQ/bWlLaJv1w1wUtDqye x+aj1t732ngyQcyhOsMWQ0GnpNoc47Sb89LeXuHpSbBYUZstCr9KIJIoyvBsiSPjRp8+ louJg19FMgWcPwzyJFJoSs45tvBBtMjaKxKAw8f/bmbXglX4+4Zsm+4hpukKTiO1YX+C bVyUxwNcv8yATZAJBAxb4ReBfaAt08bTVk0V7uPDO07Kd6+e0e78WdfG0ffBHNEmZ9cO iDTg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fDn6LMx54Jj8tVS5WSjg5QS85E5llcN/rmWDGPkaEho=; b=Q4lt/o8M25hnhShrZwzydNCZ3rxdIv/RDlzZ0gDsdLU0sNPLFPOkttbRkN+isxReaD xtsWZYYJUrI1DVzJ7MmpsBIOIbbNMLW77Pt7ywYnqoGKgTDQVA/1Oq0+crTv7oXWXyXF qPJOp5LLPySfSwclruFRb/QkiRCveZSC0dJzmS5S5FeL8KRI2hfbA5OMQcbRhos+Qn8z wQFcJTM6gBJN6V0NGaFE8LxTum4LNC1Z1y2EgVI/0F0R6pN2Ly6KcfcqTpvBWvSTYXZL Y1mKhLm2zTgI8pl907V85BbOhHNsNoPMnK+3DsVv93zh7sqbAhF8m4fXsU/gcsPQeqJa /SHw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si35191804pgk.324.2019.04.30.01.20.24; Tue, 30 Apr 2019 01:20:39 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726623AbfD3IT3 (ORCPT + 99 others); Tue, 30 Apr 2019 04:19:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:55566 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726202AbfD3IT1 (ORCPT ); Tue, 30 Apr 2019 04:19:27 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 85D05AE4F; Tue, 30 Apr 2019 08:19:26 +0000 (UTC) From: =?UTF-8?q?Michal=20Koutn=C3=BD?= To: 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, mkoutny@suse.com, rppt@linux.ibm.com, vbabka@suse.cz, ktkhai@virtuozzo.com Subject: [PATCH 1/3] mm: get_cmdline use arg_lock instead of mmap_sem Date: Tue, 30 Apr 2019 10:18:42 +0200 Message-Id: <20190430081844.22597-2-mkoutny@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190430081844.22597-1-mkoutny@suse.com> References: <20190418182321.GJ3040@uranus.lan> <20190430081844.22597-1-mkoutny@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.16.4