Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp228863imm; Mon, 21 May 2018 05:14:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq7kHFLzeQLDmrxjvc/NFJDk1ZlqpANsWZhbY0JjD607o87UA3WbO7uo4AG/gGxLPC7xKU3 X-Received: by 2002:a17:902:9a8a:: with SMTP id w10-v6mr20495916plp.333.1526904871376; Mon, 21 May 2018 05:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904871; cv=none; d=google.com; s=arc-20160816; b=YBY22g/+UNm6YsFesmflwnE2zjNUlKhTHoEHd3N80g5MgmEHEbQ4cixhfNWlTR0QF0 RTtdgbN1NWjAoyhFkQENhPYpquqvKqIPQ36iKRUH0Xa8Q48wgYIQL5Sj9b81d4T7dDoZ DgaezlePTeg/nzKFOOGXsytXMTbbhk2FeLI4TfkgIeeQYHG21l+LoGcBvZZ7zRAveZqa yJIv2PZ3GJDrDtalXeoXM6u7dUchSE5+zjAK1SSpdzlsiEh2E0k8mH0zznC5UvDVXI2Y BQXz7RaCKA+TJeJmIri58fdwwfKjPDEslwgqHYG4eZIOAhGyRYDB+pl+TN47QtgYm6Yq Yuzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=TsRH3ouWHgzhAQYFhiFBXnrpqxJ0lBInEs/yNK68FuY=; b=AhkZM8gdpRM2WL3uP8lRpiMjtdORSnR1MaB15TfNUxTefgV1nov70hP5bSjmeyynF4 0+6yg9IOQK8cRk1npHrd7uis82fMz/KRrYwZ1JXWy/ltRb3rpAyzxZbByfgZa8Y9dHtN u6hxvxNS+11HEFEhsQcT+S3p0itUJQqImI5R4iebmr4RV6Uef849z63QJeIJ/6WH+E0J 4LyV3YhOVRIoBpLvPkpMpRukudiA+kFpgmZ8j2sWGeXd696aitfcdoQA2fSyBYW0jmC8 rQcSVxcaw1/xbsB6EojQtx9s2IcJ62kHHOUlqMh0E2JqD7aH1J6HSzscJsOMn4sz3yXf 5bPQ== 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 d31-v6si14264706pld.23.2018.05.21.05.14.16; Mon, 21 May 2018 05:14:31 -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 S1752687AbeEUMNQ (ORCPT + 99 others); Mon, 21 May 2018 08:13:16 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7712 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752969AbeEUMJT (ORCPT ); Mon, 21 May 2018 08:09:19 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 5FA01ADB5B858; Mon, 21 May 2018 20:09:06 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Mon, 21 May 2018 20:09:02 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Ingo Molnar , Peter Zijlstra Subject: [PATCH 27/33] sched/debug: use match_string() helper Date: Mon, 21 May 2018 19:58:04 +0800 Message-ID: <1526903890-35761-28-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org match_string() returns the index of an array for a matching string, which can be used intead of open coded variant. Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Yisheng Xie --- kernel/sched/debug.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 15b10e2..9e34499 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -111,16 +111,14 @@ static int sched_feat_set(char *cmp) cmp += 3; } - for (i = 0; i < __SCHED_FEAT_NR; i++) { - if (strcmp(cmp, sched_feat_names[i]) == 0) { - if (neg) { - sysctl_sched_features &= ~(1UL << i); - sched_feat_disable(i); - } else { - sysctl_sched_features |= (1UL << i); - sched_feat_enable(i); - } - break; + i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp); + if (i >= 0) { + if (neg) { + sysctl_sched_features &= ~(1UL << i); + sched_feat_disable(i); + } else { + sysctl_sched_features |= (1UL << i); + sched_feat_enable(i); } } @@ -150,7 +148,7 @@ static int sched_feat_set(char *cmp) inode_lock(inode); i = sched_feat_set(cmp); inode_unlock(inode); - if (i == __SCHED_FEAT_NR) + if (i < 0) return -EINVAL; *ppos += cnt; -- 1.7.12.4