Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp897995yba; Thu, 18 Apr 2019 11:25:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFtdGv5dOb9aRpfJ7BRb6RQOzazvsEDgyEp7cwZp/ebEGwKsdVfp+iDJwa0tHwI9j97+f5 X-Received: by 2002:a17:902:2aeb:: with SMTP id j98mr30331705plb.38.1555611910310; Thu, 18 Apr 2019 11:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611910; cv=none; d=google.com; s=arc-20160816; b=A91lbh305DEqi3KFLqF6aAzSkNLp/MtR0KxPM8mchweeqkQS9rdygoAqNjLx5rivqE D33NsNYEB/f2qNCTo5meB4wc6rJXE0Rg3fDS7ehH/LFq9mly4GrkZu6xA0w+zIxUrqVo dKvzvFXRx2bCNIs6Dh4wcivJVK5uM58/L2j9k7lxyEf5lD9UQpc47RDrzb3/3jLleg87 kJ/tqd3l+yrwm/6J9xGbrO5zGacU7LoQpDB7uyU+g/G22cke22dAjOW8/ctxfjO/9Etk 2Ln6INpumBr/4Dg+28F5aoD7MUriX4PX1IK2N03/7qLCqaW3uokTn4rZL5uZi9lPmJrs 0Hog== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vC2agpd/yeTIjkC+tv6Q0HWjOpOqDC0mbvCHm0eBf4Y=; b=WNj6iX1vKygnU+m4gsy7V7sh7M7Aq47J1AUrSvdq89OkXHL+xWoaXKb0NTcHHd/X5q xuyhz82cdtBKlUagssRKTgJuvyP8+Bhdi/PQ7WZCLAle7OaB3JI+OJYjTtF1M4aYnBmz W06T4EGiAnvk5OhiBGhasXOpsniD9L13QCrcHo57JiK/flsyCkkucOn0S7c8VkspBWYN INOpOhsRvxl7/Ua2GNNOrl0vpEZRB8/KnD4uF8ZdvpS+1J/lQ9AZtdblDlGPFRKy6aCq vlVVMzXmVGDGf7cg7+YbOS4x+RMx1ff80iQLnaHgBAKhfro68iAGeoDKtp+Pu+dijGHf SHZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oCZtbd8w; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a82si2898977pfj.255.2019.04.18.11.24.55; Thu, 18 Apr 2019 11:25:10 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oCZtbd8w; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391672AbfDRSX0 (ORCPT + 99 others); Thu, 18 Apr 2019 14:23:26 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41735 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390479AbfDRSXY (ORCPT ); Thu, 18 Apr 2019 14:23:24 -0400 Received: by mail-lf1-f67.google.com with SMTP id t30so2328247lfd.8 for ; Thu, 18 Apr 2019 11:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=vC2agpd/yeTIjkC+tv6Q0HWjOpOqDC0mbvCHm0eBf4Y=; b=oCZtbd8wbvAsIKhSYoUJZQVeVFzI9LhVk5xw5A9aYv70oTCxPDa6CUjfhq+7Ko97Yw 5EBuW7fdsXGgA4duhAS6WpIwtYcQqgAk9n2TFWUG9A7Guuq6Wjh96ylkUMKabdIy43a6 8DlL8MSTSorKUkzsLvIHVbj17K+BG/zixxqBZhZOCrrzOYOTMKXRFKWY3xzHa5FX0FnE N6PJsM8S5vsd0FFiKD5cO1kUvacWe5/8AigkrFKVHcH1e2gmueli4YEM7P5c4pgH8ojH IXmHDGo8zSl1fe/FBh+n8Fy+4L+B3KeT+Qf9JY48R+SfJhpOvzSGNTMAIWBWK6bhaoHX t7lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=vC2agpd/yeTIjkC+tv6Q0HWjOpOqDC0mbvCHm0eBf4Y=; b=VgH6eNXtgng+J9tSr3StlyQdvN+gqTpdO+/SwT/ceiQTcZpBWN460dBXeMfR+BII0t kfMw2LC0FcomSzG1BfeKFZ5on7DS+3UHfznMHDttBlRhdXr1L3hDGi7OwqW5C7uYljOB hUExL7cS6jZZUZoZQwLs3NCS9ccZFgWKkKyZ2QJMb+nhgze3JyHzZGgmGo3t3iEKX7ru oepYEtpYUPOHwU3/juMtM8e53zhlXny4HmKofFmmBomQYW5iAMTmfEFmH6hJloKJH4ka DezBadSQhKQpL37AsxpPrZH8Ard0Pdb1urxAR27xaZJ6pnaceaq+k6bRJejglFjmV40k mQhQ== X-Gm-Message-State: APjAAAXpI30dMc8EGMN/OZei4Lo8pJX02XxdrT7ZClliZyCIZPddnYzk WrrMcBgdsB9FhwlW3iGiuh0= X-Received: by 2002:a19:c51a:: with SMTP id w26mr50367270lfe.59.1555611802703; Thu, 18 Apr 2019 11:23:22 -0700 (PDT) Received: from uranus.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id n28sm90162lfi.79.2019.04.18.11.23.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2019 11:23:22 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id B8D49460E21; Thu, 18 Apr 2019 21:23:21 +0300 (MSK) Date: Thu, 18 Apr 2019 21:23:21 +0300 From: Cyrill Gorcunov To: Michal =?iso-8859-1?Q?Koutn=FD?= Cc: mhocko@kernel.org, akpm@linux-foundation.org, arunks@codeaurora.org, brgl@bgdev.pl, geert+renesas@glider.be, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mguzik@redhat.com, rppt@linux.ibm.com, vbabka@suse.cz, Laurent Dufour Subject: Re: [PATCH] prctl_set_mm: downgrade mmap_sem to read lock Message-ID: <20190418182321.GJ3040@uranus.lan> References: <20190417145548.GN5878@dhcp22.suse.cz> <20190418135039.19987-1-mkoutny@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190418135039.19987-1-mkoutny@suse.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 18, 2019 at 03:50:39PM +0200, Michal Koutn? wrote: > I learnt, it's, alas, too late to drop the non PRCTL_SET_MM_MAP calls > [1], so at least downgrade the write acquisition of mmap_sem as in the > patch below (that should be stacked on the previous one or squashed). > > Cyrill, you mentioned lock changes in [1] but the link seems empty. Is > it supposed to be [2]? That could be an alternative to this patch after > some refreshments and clarifications. > > > [1] https://lore.kernel.org/lkml/20190417165632.GC3040@uranus.lan/ > [2] https://lore.kernel.org/lkml/20180507075606.870903028@gmail.com/ > > ======== > > Since commit 88aa7cc688d4 ("mm: introduce arg_lock to protect > arg_start|end and env_start|end in mm_struct") we use arg_lock for > boundaries modifications. Synchronize prctl_set_mm with this lock and > keep mmap_sem for reading only (analogous to what we already do in > prctl_set_mm_map). > > Also, save few cycles by looking up VMA only after performing basic > arguments validation. > > Signed-off-by: Michal Koutn? Reviewed-by: Cyrill Gorcunov As Laurent mentioned we might move vma lookup before the spinlock, but this might be done on top of the series.