From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751556AbbIEFT1 (ORCPT ); Sat, 5 Sep 2015 01:19:27 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:57610 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751349AbbIEFTS (ORCPT ); Sat, 5 Sep 2015 01:19:18 -0400 Date: Sat, 5 Sep 2015 06:19:15 +0100 From: Al Viro To: yalin wang Cc: Linus Torvalds , Eric Dumazet , Oleg Nesterov , "linux-kernel@vger.kernel.org" , Andrew Morton , Thomas Gleixner , Ingo Molnar , Maciej =?utf-8?Q?=C5=BBenczykowski?= Subject: Re: [PATCH] task_work: remove fifo ordering guarantee Message-ID: <20150905051915.GC22011@ZenIV.linux.org.uk> References: <1440816150.8932.123.camel@edumazet-glaptop2.roam.corp.google.com> <20150829124921.GA14973@redhat.com> <1440856650.8932.144.camel@edumazet-glaptop2.roam.corp.google.com> <1440857473.8932.146.camel@edumazet-glaptop2.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 31, 2015 at 01:22:26PM +0800, yalin wang wrote: > why not provide API like: > fput() > fput_nosync() ? > > because synchronous version are reasonable and safe in most time, > let the user to select which version to use is more feasible, no matter if it is kthread or not. Synchronous version is *NOT* safe in a lot of situations, from "deep enough in kernel stack" to "now a function seven levels out in call chain happens to hold a mutex grabbed elsewhere inside a mutex taken by unexpected ->release() instance, causing a deadlock", etc. It's not sync vs. async; we still guarantee execution before return from syscall. The only case when we really get async is kernel threads - there we do *not* return to userland at all, so we have to schedule it really asynchronous. Which is why we need an explicit sync version (for kernel threads only, not exported, don't use unless you really understand what you are doing and can explain why that particular case is safe, etc.)