Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3789177imu; Fri, 18 Jan 2019 17:56:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN7i1NHn9zF7/InxLwdYHN3yIu3E46Jnkl0uJ5I3perp1oVo119A0wlMC1ChxQiXcgP7ZMn4 X-Received: by 2002:a17:902:2867:: with SMTP id e94mr21611566plb.264.1547862965955; Fri, 18 Jan 2019 17:56:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547862965; cv=none; d=google.com; s=arc-20160816; b=bYLZNuEghRliTWz1PsxAy8ErPqnMdpYDl0GvFlTj7fdGWaqXjhbtFN4cP+0sLX1syv q34k6XLw3sLC+xs4lUrgE7rtEHZwWTGEIRJdVlhfQ2kqzHumyLRQ+zJBiwDttxrrxbrb F9TvsNDKyeYQARGXnSBfyosxVQ0i1GW7cGlwVw6ZVHlQZgnh+K0Z5EXhYwM0ywK1c8Ei NuB41/FB5OyGo7taLVQZYRpRJSsoGygZfljoBBZtEWyztuu1i7yL78Bp4SpRrgLincbf 9wQyGLasGO5RwLKa7rB03NjyZcVWGt3ftKwibPSq1Ue807jFWtBiYDkrmyMRkM8uEmoy /fvw== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uA2xWLve8Th5/na34Noxswo34IRYpFbURVS0OXk2Y+4=; b=YBgpoyHVvrWbVFNExV6xuhpq4hC65tdp5IXAAYkUTIaNTpeo1VZrB7Sb6Xv/JT35mv jKluiiFcv0qi3Snnp0p2YYMoBaFMJNE/f3spv2Pea98z9K/8RBaMx5+2iSLzlaLNBRlz 5zShzLtkofwYzLRoCPGrRa0UdrYyQJDH5XmXTkgEnfk8V7lwRPfSTFsbGANm76bsilLB FRPiDKGQMph70EShV3qlHYxrJTVqp/nOUhEfMU/ImiEWH0LWV5EG0o3ufPooj2g1cThS LjcAd+66rSlebpjYLzpkx7GlXmEQMYSp0vQZgp/ZD9WjxFhUn+KKdkC3ILfKq3SHSIFb Lllw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=wvmflCNd; 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 85si5983775pfc.145.2019.01.18.17.55.49; Fri, 18 Jan 2019 17:56:05 -0800 (PST) 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=@joelfernandes.org header.s=google header.b=wvmflCNd; 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 S1729093AbfASBx6 (ORCPT + 99 others); Fri, 18 Jan 2019 20:53:58 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:37856 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbfASBx6 (ORCPT ); Fri, 18 Jan 2019 20:53:58 -0500 Received: by mail-qt1-f194.google.com with SMTP id t33so17357248qtt.4 for ; Fri, 18 Jan 2019 17:53:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uA2xWLve8Th5/na34Noxswo34IRYpFbURVS0OXk2Y+4=; b=wvmflCNdwPrJbnXhBU1O9qAEh9KVIRyZ/yn+iVd3oyZ/4ADrtDfcawNJYPzJOlTOcn yHHknYOk16lznM6rppvst8aqhmmpZ8fEZ3STAOFjPB0V142rIs5wqCgm+A/2T4mx4X5Q NuK49aZyNo+Fr3LkWj72mhjNAjZJ31F83bNIg= 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:in-reply-to:user-agent; bh=uA2xWLve8Th5/na34Noxswo34IRYpFbURVS0OXk2Y+4=; b=BPbvvaH6k3czFNucEdzx09WpShgwqUR2M9sAZvYW94KrdkdHgmD+7vpYmFwc/11VX4 YH7J5YH904nEyCNXO+8KXFGiXnMJylWDKiOzrDFIYs5iWrAiT+xyEl7buz9sXEftnWCO 8LdPsAMyVwgnrlw7k7uve6+n50sJI+b8UIh8iq6rfuckwE3Se2N2MnjiNPBn4u0pExsi Tw5CQkCesZoCxglkFQE1omdaun/FPiT4Gu0XNjrL7+Sy1hARNd3r7kQzsVMzE9nxqocy vOfSOmlCiw0kDbc0pVE+Gbgy88RM8K9HJqceEMIw0Cm0Pb5ne6J8JRaxYUkg2dX0R1nz m0uQ== X-Gm-Message-State: AJcUukfw6AOE6hctvdtcwav/XHbi8m+GelvdvmtWAKhHKGp3hYUrKo1C lssdtGvqWr6ypQyiblKzdVHOOw== X-Received: by 2002:a0c:b044:: with SMTP id l4mr18081949qvc.80.1547862837029; Fri, 18 Jan 2019 17:53:57 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id h35sm63140168qth.59.2019.01.18.17.53.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 17:53:56 -0800 (PST) Date: Fri, 18 Jan 2019 20:53:55 -0500 From: Joel Fernandes To: Hugo Lefeuvre Cc: Greg Kroah-Hartman , Greg Hartman , Alistair Strachan , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Christian Brauner , Ingo Molnar , Peter Zijlstra , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/wait: introduce wait_event_freezable_hrtimeout Message-ID: <20190119015355.GA115342@google.com> References: <20190117224135.GC8100@hle-laptop.local> <20190118151941.GB187589@google.com> <20190118170801.GA4537@hle-laptop.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190118170801.GA4537@hle-laptop.local> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 18, 2019 at 06:08:01PM +0100, Hugo Lefeuvre wrote: [...] > > > +/* > > > + * like wait_event_hrtimeout() -- except it uses TASK_INTERRUPTIBLE to avoid > > > + * increasing load and is freezable. > > > + */ > > > +#define wait_event_freezable_hrtimeout(wq_head, condition, timeout) \ > > > > You should document the variable names in the header comments. > > Agree. This comment was copy/pasted from wait_event_freezable_timeout, > should I fix it there as well? > > > Also, this new API appears to conflict with definition of 'freezable' in > > wait_event_freezable I think, > > > > wait_event_freezable - sleep or freeze until condition is true. > > > > wait_event_freezable_hrtimeout - sleep but make sure freezer is not blocked. > > (your API) > > > > It seems to me these are 2 different definitions of 'freezing' (or I could be > > completely confused). But in the first case it calls try_to_freeze after > > schedule(). In the second case (your new API), it calls freezable_schedule(). > > > > So I am wondering why is there this difference in the 'meaning of freezable'. > > In the very least, any such subtle differences should be documented in the > > header comments IMO. > > It appears that freezable_schedule() and schedule(); try_to_freeze() are > almost identical: > > static inline void freezable_schedule(void) > { > freezer_do_not_count(); > schedule(); > freezer_count(); > } > > and > > static inline void freezer_do_not_count(void) > { > current->flags |= PF_FREEZER_SKIP; > } > > static inline void freezer_count(void) > { > current->flags &= ~PF_FREEZER_SKIP; > /* > * If freezing is in progress, the following paired with smp_mb() > * in freezer_should_skip() ensures that either we see %true > * freezing() or freezer_should_skip() sees !PF_FREEZER_SKIP. > */ > smp_mb(); > try_to_freeze(); > } > > as far as I understand this code, freezable_schedule() avoids blocking the > freezer during the schedule() call, but in the end try_to_freeze() is still > called so the result is the same, right? > I wonder why wait_event_freezable is not calling freezable_schedule(). It could be something subtle in my view. freezable_schedule() actually makes the freezer code not send a wake up to the sleeping task if a freeze happens, because the PF_FREEZER_SKIP flag is set, as you pointed. Whereas wait_event_freezable() which uses try_to_freeze() does not seem to have this behavior and the task will enter the freezer. So I'm a bit skeptical if your API will behave as expected (or at least consistently with other wait APIs). > That being said, I am not sure that the try_to_freeze() call does anything > in the vsoc case because there is no call to set_freezable() so the thread > still has PF_NOFREEZE... I traced this, and PF_NOFREEZE is not set by default for tasks. thanks, - Joel