From patchwork Tue May 28 10:32:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 10964595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A099112C for ; Tue, 28 May 2019 10:34:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BBEF285C9 for ; Tue, 28 May 2019 10:34:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 204F128813; Tue, 28 May 2019 10:34:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CB282285C9 for ; Tue, 28 May 2019 10:34:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVZQ1-0004XI-Hd; Tue, 28 May 2019 10:33:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVZQ0-0004X7-FJ for xen-devel@lists.xenproject.org; Tue, 28 May 2019 10:33:20 +0000 X-Inumbo-ID: 00dc4330-8134-11e9-baca-f707ef87a1cd Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 00dc4330-8134-11e9-baca-f707ef87a1cd; Tue, 28 May 2019 10:33:16 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 012A7AE4D; Tue, 28 May 2019 10:33:15 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Tue, 28 May 2019 12:32:14 +0200 Message-Id: <20190528103313.1343-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190528103313.1343-1-jgross@suse.com> References: <20190528103313.1343-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 01/60] xen/sched: only allow schedulers with all mandatory functions available X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some functions of struct scheduler are mandatory. Test those in the scheduler initialization loop to be present and drop schedulers not complying. Signed-off-by: Juergen Gross Reviewed-by: Dario Faggioli --- V1: new patch --- xen/common/schedule.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 66f1e2611b..72d8be3906 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1726,9 +1726,33 @@ void __init scheduler_init(void) for ( i = 0; i < NUM_SCHEDULERS; i++) { +#define sched_test_func(f) \ + if ( !schedulers[i]->f ) \ + { \ + printk("scheduler %s misses .%s, dropped\n", \ + schedulers[i]->opt_name, #f); \ + schedulers[i] = NULL; \ + } + + sched_test_func(init); + sched_test_func(deinit); + sched_test_func(pick_cpu); + sched_test_func(alloc_vdata); + sched_test_func(free_vdata); + sched_test_func(switch_sched); + sched_test_func(do_schedule); + +#undef sched_test_func + if ( schedulers[i]->global_init && schedulers[i]->global_init() < 0 ) + { + printk("scheduler %s failed initialization, dropped\n", + schedulers[i]->opt_name); schedulers[i] = NULL; - else if ( !ops.name && !strcmp(schedulers[i]->opt_name, opt_sched) ) + } + + if ( schedulers[i] && !ops.name && + !strcmp(schedulers[i]->opt_name, opt_sched) ) ops = *schedulers[i]; }