From owner-freebsd-hackers@freebsd.org Fri Apr 20 12:08:57 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 508B8F98B48 for ; Fri, 20 Apr 2018 12:08:57 +0000 (UTC) (envelope-from aliovx@gmail.com) Received: from mail-ot0-x22a.google.com (mail-ot0-x22a.google.com [IPv6:2607:f8b0:4003:c0f::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CF7217E727 for ; Fri, 20 Apr 2018 12:08:56 +0000 (UTC) (envelope-from aliovx@gmail.com) Received: by mail-ot0-x22a.google.com with SMTP id i5-v6so9358869oth.1 for ; Fri, 20 Apr 2018 05:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=VAatN4sRwCF4x2E4R8Mviqu6PljbDvNJMWboqBwPJBE=; b=sGqiZTasisrxfMo/DqbsS5O9YhQrM+Y1P4Fp2lhdCXBzB/mxzogawJ2zYlZRepAcHJ 1R5spjaDS+U+v1rumyY3a6w8pd8X0wscLsyB3cchw0EgUUlzHbvdbXjhGFgJ2T7iXkqz AbzfR1cx8+ylnwRYXBYWTguRmoyqgtRldCW85Aw2yyk8IxitdNh6AC9N7aNV3gMyZdpN 4D1JW6FRg1txrmFbFIlvCG3xIA4tEnGXXibJPE5eq+NeKdCu8mmxKQ2fCp9k8w3P32WC CYP6x9mdHgKihxV/uelAeAdmjrUJfFUPba0upPcA4PAeVV6U0IJVw5qWZtwt71VfaAwf tehA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=VAatN4sRwCF4x2E4R8Mviqu6PljbDvNJMWboqBwPJBE=; b=oGfCjlGQf6scyzn3xxtrmmKGlc+SWckhXH1QtHQbFun89eGrA/DMzKONCfVFP0QWmc Sz72RTaMy1bCcOCN0jHRt1+GtseKIOo9i1Znhd4AZddBwQhdw8mAaJKkY8weP9Z59AM+ oHxOxZdHEGA0aXbXP0BYsZHSQj1K4UKUIoo3CfxUAb/2n5NEZ1eoNpcBj6yCmi7S+rJy fRx3DZKg+MoLJ7IymNM3YLHf4cS/wTkClKp58qKUFS9QdRZDQj8O2TCgez+sgwpUDvHM qfv09uCMSbDmDGqgGx2QlideEb64+izn+a+8N1C51+gbFSP4PMhpZhaJh4O42bCkgCRg uh9A== X-Gm-Message-State: ALQs6tDIl3KtWYbEqBwdlFm7+AYzzntblnyRdew/RqQQxWSGpXn3Wgxk V04/YARBas6SVaEOayhx2yO/yvestphPVLMBXUJUdA== X-Google-Smtp-Source: AIpwx48E163fzRHkRE7XrYK86GYpH1QOVNuuAuVHIGyVkGm3htj+jojQZPogq8kUkc9HoLjoIXCkyCh8gRYqVrxYwZ4= X-Received: by 2002:a9d:27a6:: with SMTP id c35-v6mr5656895otb.271.1524226136020; Fri, 20 Apr 2018 05:08:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.201.50.38 with HTTP; Fri, 20 Apr 2018 05:08:55 -0700 (PDT) From: Ali Abdallah Date: Fri, 20 Apr 2018 14:08:55 +0200 Message-ID: Subject: sched_setscheduler returns EPERM instead of EINVAL when sched_priority is out of range To: freebsd-hackers@freebsd.org X-Mailman-Approved-At: Fri, 20 Apr 2018 12:21:19 +0000 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Apr 2018 12:08:57 -0000 Hello, I got quite confused when I was getting EPERM from the sched_setscheduler system call on FreeBSD 11.1, thinking at the beginning that I had a permission problem (program uses setuid, and it is launched by normal user). After, I realized that my sched_param.sched_priority value was simply out of range. According to the documentation, [EINVAL] should be returned if the value of the policy argument is invalid, or one or more parameters contained in param is outside the valid range! In ksched.c line 180, the ksched_setscheduler functions returns EPERM when (param->sched_priority >= P1B_PRIO_MIN && param->sched_priority <= P1B_PRIO_MAX), on other Unices, I get EINVAL as expected. Is there is a reason for why FreeBSS handles this differently? Cheers, Ali