Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10418918ybi; Wed, 24 Jul 2019 22:53:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqznnWtBQGA11tdVZfFOMV/lO0MTkhl4uTBTDc5X5zPKNioKykPtpjfp6r48Xq80oUUQ4e+o X-Received: by 2002:a62:15c3:: with SMTP id 186mr15476912pfv.141.1564033989339; Wed, 24 Jul 2019 22:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033989; cv=none; d=google.com; s=arc-20160816; b=BAfqHqvcZrOl4lLehQrWKvEmgrn4NTTTUrbdjqxBxNYehnOjEffecdZgbHUQTa1oW2 fb2TFtQykP0DwD1hK80l8wxzPD9X5ZAnSSeMLFlJ7ndEiIpEI0sb7V0WaHTc3Y42FGhI qirY+zrOrsfYPhYJP4gIPSoqZBORss6EoxukIw7VLanMkVbPw3D9T+bpsGv2iiC58yu8 jWuK52yjsyyp2mmj1skMg1hpBZhPe3eQ1sjwLg4fljJg+vgLfJtjtaHwuyeeRjARz1sY t/mMlUXAfzlYHy6CYxhGVUQ0Q8m4swew8UudonG9sEgbsAMGEv/0TRyoyXwaXbwdjO5l +0TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=DyCZKpWof4oh90SqkTUedvTFFnBFpVlsvDqyTjG81Go=; b=hAd1s6QtMY4haFfQ5w4QnwI+yclU7sz7tWqj5BUFlZ/1jTvMTJy8OymDGuksCLBQJM OS/CuVB26H62HYTRTlYJhX3QDa4JiaXeik4yB3pP01UsV26NtfBMWI+P9+lQ5+/qeJ2e 6lPyGV2FFeQT8YpT4SeC8vi0veilaCBNEsiWyHj92K4nUgkca4+WyEjtPKLFPO4FafH6 SStadYAA7qb55eRCiyhzwPhTb0z8jOrGFgz+CI0wK6Bk0WLA+5EOw5anN1l+DyuHVbfI jRCLV+8gIkmmeiPvFVgp6wXh7kEiTOEpJqiyN+bwFrkHbMQrpVXmfKzE6juRrSuMPm6Y OZ4Q== ARC-Authentication-Results: i=1; mx.google.com; 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 f7si7436691pgs.210.2019.07.24.22.52.54; Wed, 24 Jul 2019 22:53:09 -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; 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 S2389715AbfGYDLB (ORCPT + 99 others); Wed, 24 Jul 2019 23:11:01 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:57997 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388594AbfGYDLB (ORCPT ); Wed, 24 Jul 2019 23:11:01 -0400 X-IronPort-AV: E=Sophos;i="5.64,305,1559491200"; d="scan'208";a="72161282" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Jul 2019 11:11:00 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 10AD04CDE64D; Thu, 25 Jul 2019 11:10:59 +0800 (CST) Received: from [10.167.215.46] (10.167.215.46) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.439.0; Thu, 25 Jul 2019 11:11:00 +0800 Message-ID: <5D391DC0.3050100@cn.fujitsu.com> Date: Thu, 25 Jul 2019 11:10:56 +0800 From: Yang Xu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: Andrew Morton CC: , Subject: Re: [PATCH v2] sys_prctl(): remove unsigned comparision with less than zero References: <20190723094809.GE4832@uranus.lan> <1563934308-20833-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> <20190724191448.4db70a34f8b89bd8bdc085f5@linux-foundation.org> In-Reply-To: <20190724191448.4db70a34f8b89bd8bdc085f5@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.215.46] X-yoursite-MailScanner-ID: 10AD04CDE64D.A18B6 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xuyang2018.jy@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org on 2019/07/25 10:14, Andrew Morton wrote: > On Wed, 24 Jul 2019 10:11:48 +0800 Yang Xu wrote: > >> Currently, when calling prctl(PR_SET_TIMERSLACK, arg2), arg2 is an >> unsigned long value, arg2 will never< 0. Negative judgment is >> meaningless, so remove it. >> >> ... >> >> --- a/kernel/sys.c >> +++ b/kernel/sys.c >> @@ -2372,7 +2372,7 @@ 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 == 0) >> current->timer_slack_ns = >> current->default_timer_slack_ns; > A number of years ago Linus expressed approval of such comparisons with > unsigned quantities. He felt that it improves readability a little - > the reader doesn't have to scroll back and check the type. Hi Andrew It sounds good. ButWe still have to look at the actual situation. In here, this comparisons with unsigned quantities doesn't improvereadability. In turn, the code give user a wrongdescription as man page said " If arg2 is less than or equal to zero, the "current" timer slack is reset to the thread's default" timer slack value." If we set -1 in user space, we pass it into kernel as ULONG_MAX, it will not use default timer_slack value. Also, I guess that if value has no actual sense we can use this comparisons. In here, arg2 represents slack time. time will never less than 0. ps: whether we change or not change this comparisons, it doesn't affect logic. So if you think this patch is meaningless, I will accept it. Thanks Yang Xu > > > >