Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2991717pxa; Tue, 18 Aug 2020 03:46:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydN3eL3CgNCZ3Jj3yWoYop+sgHF/oiKBkRitCn0m696ZIEfTm4C6/+rArd/eh6Sr0f1ZsJ X-Received: by 2002:a05:6402:c81:: with SMTP id cm1mr18528069edb.256.1597747617172; Tue, 18 Aug 2020 03:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597747617; cv=none; d=google.com; s=arc-20160816; b=CTUn1UGoEtY6FUa/GS4A+mBquFxWuPyIurvUObYah+oNi88PPCPVc5lVE4zohqCZ0z oHLa+NxEkc/sjI0006/d7pir72DpYEC4Wv5JlOxz7YZwnD1YcdOFyMvSVKM6C4eR9s1x rOuUgiuL5EaiOgNnJnn31QnCKC/Qdb7U6blDBYvRh/fq+sz0dSnAD0HN7jLEIzwuQ2rq hbLR2RjaI9/Xjlcs/vhfVbYWWQCTZoTnL24x8d1zSrilQrBdjfbz/RO/mvTdiCGpPuKO G3ZabpedKbWHfIWzXolh8FfPRPb2MX5EPC6K7hL9of2bq3goz2mQ3qPh3rQJai7l1c7l lzMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=HCWDrwssA1MHGUfz52sNfKPCYzapliHP2P6MsmdsQnY=; b=M+Lk4wwotqTl8yZjrujCx98WIGNGg7wQAa9kWBIk3UnLDywCwIxSTAZMrmFHF+nmxl iBwB/ncculyxsxAcPHl/MY0C74yiDgeSJoC+APRIx9EXRCFW3NJ25DecdrIay9AtxPRM j32uXjXGf4+8Dcfbo64d5mNmbafqp3o5aorsOZMHfqgUtBgCNaNRhV0ntIx21ELljlov ARzJHFXwZojdXotAC0iKJzcaWwLVg9DN7dc1Jpx1yJOIYm4ZnQdJpOaHNjbnThKjkjNu blKO1ppCxv5/V1MacmK3qaVlqyCMG/xsfu+IgbSawJQ9yxrldRxYKl0YW0d2Ll1fyLAr YDPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id od24si13651314ejb.630.2020.08.18.03.46.33; Tue, 18 Aug 2020 03:46:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726763AbgHRKnt (ORCPT + 99 others); Tue, 18 Aug 2020 06:43:49 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:39312 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbgHRKns (ORCPT ); Tue, 18 Aug 2020 06:43:48 -0400 Received: from ip5f5af70b.dynamic.kabel-deutschland.de ([95.90.247.11] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k7z5m-0003jk-JH; Tue, 18 Aug 2020 10:43:46 +0000 Date: Tue, 18 Aug 2020 12:43:45 +0200 From: Christian Brauner To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, criu@openvz.org, bpf@vger.kernel.org, Linus Torvalds , Alexander Viro , Oleg Nesterov , Cyrill Gorcunov , Jann Horn , Kees Cook , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Jeff Layton , Miklos Szeredi , Matthew Wilcox , "J. Bruce Fields" , Matthew Wilcox , Trond Myklebust , Chris Wright , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh Subject: Re: [PATCH 12/17] proc/fd: In fdinfo seq_show don't use get_files_struct Message-ID: <20200818104345.n5ugxlzuv5iuggqs@wittgenstein> References: <87ft8l6ic3.fsf@x220.int.ebiederm.org> <20200817220425.9389-12-ebiederm@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200817220425.9389-12-ebiederm@xmission.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 17, 2020 at 05:04:20PM -0500, Eric W. Biederman wrote: > When discussing[1] exec and posix file locks it was realized that none > of the callers of get_files_struct fundamentally needed to call > get_files_struct, and that by switching them to helper functions > instead it will both simplify their code and remove unnecessary > increments of files_struct.count. Those unnecessary increments can > result in exec unnecessarily unsharing files_struct which breaking > posix locks, and it can result in fget_light having to fallback to > fget reducing system performance. > > Instead hold task_lock for the duration that task->files needs to be > stable in seq_show. The task_lock was already taken in > get_files_struct, and so skipping get_files_struct performs less work > overall, and avoids the problems with the files_struct reference > count. > > [1] https://lkml.kernel.org/r/20180915160423.GA31461@redhat.com > Suggested-by: Oleg Nesterov > Signed-off-by: "Eric W. Biederman" > --- Acked-by: Christian Brauner