Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8484856ybi; Tue, 23 Jul 2019 09:22:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4WC9s2UopHEiPkUzZCOzOc/DLIS7Iu3aBNJhjDGXgbrZO/5EfU7kxPTlzL+qIuY7OEwJD X-Received: by 2002:a17:90a:f491:: with SMTP id bx17mr85069803pjb.118.1563898928651; Tue, 23 Jul 2019 09:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563898928; cv=none; d=google.com; s=arc-20160816; b=dhWR7ka/8/dMKHqdvVfkPCBv6iueUEvLTh3/lM7xXBYieggnOJ3TeB/JfepdPD8Ppp nTeZuC6U0riv8u2jVXGtUJLQX6yatCL6R9r9lOLzFzmYjQGjky5xR56u1pJ0/HAZxyHJ 6Uiy5wa+m1KEuF3RvBSMQ5QC2Lm6HOQ6wWv6ux3c21nXcPPX1kKj6We8qps3Z2PQTCAB grm87cUapikUiS6CW4oOgrqGBNn5RO04t8dKmVaXRotP5bg9FYzkDB4HG77EW9wwK0dO Vmoba4WS9xWI4MEJETiCnDUv8kR+cV6ZEvyjSU57ax1aYOZNKULXMMV9tx8Ht3wCc1+q 3biw== 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=+0af/di8neZDo+ch0WCMnUUscgz6jkCHX1aQFfEODRI=; b=pq3/0TFcmcHd9/PXKcaaandwY3R6yTxsZ1tbvUfXOHnGXaT3vn66a32EFioKBHdLFI kKsLfBtnPP5e5IghMK+P4DC3BecPxEXO+Xr/MmZfba2LE5WYErE+PgblK0ItW76gaIAM saEpnGFah19ePE1r0vPqZYqRnDizRlzNTDXyR0HmgvJ5vsQevB/1/6DWnB664mm2ElJi 4D+9HLLnDAKMoEhm154M1S+60fvmrD+dlFyTvzcHfyxtYtU2nIrZuLN8tlHspLPPncTA um+GS0YHJthxU3+Oq0Qud14BlNfH4wgGOpwQIpPcxNhSVeOj0zj3g+KhErkD7Ey2JL6l AScw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MhxsHlPu; 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 o33si11351948plb.408.2019.07.23.09.21.52; Tue, 23 Jul 2019 09:22:08 -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=MhxsHlPu; 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 S2388324AbfGWHXm (ORCPT + 99 others); Tue, 23 Jul 2019 03:23:42 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:36371 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732748AbfGWHXm (ORCPT ); Tue, 23 Jul 2019 03:23:42 -0400 Received: by mail-lf1-f65.google.com with SMTP id q26so28610430lfc.3 for ; Tue, 23 Jul 2019 00:23:40 -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:in-reply-to:user-agent; bh=+0af/di8neZDo+ch0WCMnUUscgz6jkCHX1aQFfEODRI=; b=MhxsHlPusMQTH9eD1GJz8oyq7mT2YG5azSgg7bRoDo7VEMsxXYZF7j7nP7mlsaXfvq ie0+9Uc0WK+0n7xUlotoO6A7L93mSGjUo52282K2iQMr9BINiI0oEUz/FM5FDYvy9n3A sDEacNGZUnsnpxZ7QJFQwvaxb8WlvykLh/u/uNDWXQw5HFMiL7aQiMrgpw3CTBVfqCN6 F+CBxTIo6nM/VHzanMg9QT+O+KK6cahYV829TI+r1/t4P4DzU8MuxhvZ9VUua1rjF0HI uEg8Sx+gFzTmqvL69hCiqoQOEccliaITZYA+wLCsyxycYd7+aIxlFbaiR9M8Xaq7o6vJ okLg== 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=+0af/di8neZDo+ch0WCMnUUscgz6jkCHX1aQFfEODRI=; b=bz8qONEAGl+lZLsr+N2I+9VQIa8Irzb2+qNml/ebebed85TPyMrK5dg1bVNO1MMovW vTke1oDLdi5cDXkkLCudtP6Q7iEyYQh4f1U8ZjIgeCDi2BoInDU4dPvmHEuu0geGe+80 K8xt1tXczt3uh2O1FtUAJ5297yQsTDlsgUKs3YOc+FdNNofyu8Ia6MfroLqK/VXhqfyw eFRkaWuPWXAsH0b1kGgmQsNKTtpqL3tCCYQupu6hzq/sVY5LU+aPxhn2aHlRScjwJzLX 1TrnBRVMMxM3iCWzZBjTuv4fa1eXxeMmFuObW5Yw/o4P7T4jGVSJh6nPjoA192NtS/Gk RpSQ== X-Gm-Message-State: APjAAAXpcEdv5r1OY39RHtVyLjLXJoqTG2RypnadX/BueENsF2dbbBQt nEUJtnm2W4raEEOw0TvBPVc+0UG1dcE= X-Received: by 2002:a19:c80b:: with SMTP id y11mr33542945lff.81.1563866620067; Tue, 23 Jul 2019 00:23:40 -0700 (PDT) Received: from uranus.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id v202sm6378235lfa.28.2019.07.23.00.23.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 23 Jul 2019 00:23:39 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id E582C460729; Tue, 23 Jul 2019 10:23:38 +0300 (MSK) Date: Tue, 23 Jul 2019 10:23:38 +0300 From: Cyrill Gorcunov To: Yang Xu Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sys_prctl(): simplify arg2 judgment when calling PR_SET_TIMERSLACK Message-ID: <20190723072338.GD4832@uranus.lan> References: <1563852653-2382-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1563852653-2382-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 23, 2019 at 11:30:53AM +0800, Yang Xu wrote: > arg2 will never < 0, for its type is 'unsigned long'. So negative > judgment is meaningless. > > Signed-off-by: Yang Xu > --- > kernel/sys.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/kernel/sys.c b/kernel/sys.c > index 2969304c29fe..399457d26bef 100644 > --- a/kernel/sys.c > +++ b/kernel/sys.c > @@ -2372,11 +2372,11 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, > error = current->timer_slack_ns; > break; > case PR_SET_TIMERSLACK: > - if (arg2 <= 0) > + if (arg2) > + current->timer_slack_ns = arg2; > + else > current->timer_slack_ns = > current->default_timer_slack_ns; > - else > - current->timer_slack_ns = arg2; > break; > case PR_MCE_KILL: > if (arg4 | arg5) From a glance it looks correct to me, but then... 1) you might simply compare with zero, iow if (arg2 == 0) instead of changing 7 lines 2) according to man page passing negative value should be acceptable, though it never worked as expected. I've been grepping "git log" for this file and the former API is coming from commit 6976675d94042fbd446231d1bd8b7de71a980ada Author: Arjan van de Ven Date: Mon Sep 1 15:52:40 2008 -0700 hrtimer: create a "timer_slack" field in the task struct which is 11 years old by now. Nobody complained so far even when man page is saying pretty obviously PR_SET_TIMERSLACK (since Linux 2.6.28) Each thread has two associated timer slack values: a "default" value, and a "current" value. This operation sets the "current" timer slack value for the calling thread. If the nanosecond value supplied in arg2 is greater than zero, then the "current" value is set to this value. If arg2 is less than or equal to zero, the "current" timer slack is reset to the thread's "default" timer slack value. So i think to match the man page (and assuming that accepting negative value has been supposed) we should rather do if ((long)arg2 < 0) Thoughts?