Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  select_cpu_vtime.bpf.c   Sprache: C

 
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * A scheduler that validates that enqueue flags are properly stored and
 * applied at dispatch time when a task is directly dispatched from
 * ops.select_cpu(). We validate this by using scx_bpf_dsq_insert_vtime(),
 * and making the test a very basic vtime scheduler.
 *
 * Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
 * Copyright (c) 2024 David Vernet <dvernet@meta.com>
 * Copyright (c) 2024 Tejun Heo <tj@kernel.org>
 */


#include <scx/common.bpf.h>

char _license[] SEC("license") = "GPL";

volatile bool consumed;

static u64 vtime_now;

#define VTIME_DSQ 0

static inline bool vtime_before(u64 a, u64 b)
{
 return (s64)(a - b) < 0;
}

static inline u64 task_vtime(const struct task_struct *p)
{
 u64 vtime = p->scx.dsq_vtime;

 if (vtime_before(vtime, vtime_now - SCX_SLICE_DFL))
  return vtime_now - SCX_SLICE_DFL;
 else
  return vtime;
}

s32 BPF_STRUCT_OPS(select_cpu_vtime_select_cpu, struct task_struct *p,
     s32 prev_cpu, u64 wake_flags)
{
 s32 cpu;

 cpu = scx_bpf_pick_idle_cpu(p->cpus_ptr, 0);
 if (cpu >= 0)
  goto ddsp;

 cpu = prev_cpu;
 scx_bpf_test_and_clear_cpu_idle(cpu);
ddsp:
 scx_bpf_dsq_insert_vtime(p, VTIME_DSQ, SCX_SLICE_DFL, task_vtime(p), 0);
 return cpu;
}

void BPF_STRUCT_OPS(select_cpu_vtime_dispatch, s32 cpu, struct task_struct *p)
{
 if (scx_bpf_dsq_move_to_local(VTIME_DSQ))
  consumed = true;
}

void BPF_STRUCT_OPS(select_cpu_vtime_running, struct task_struct *p)
{
 if (vtime_before(vtime_now, p->scx.dsq_vtime))
  vtime_now = p->scx.dsq_vtime;
}

void BPF_STRUCT_OPS(select_cpu_vtime_stopping, struct task_struct *p,
      bool runnable)
{
 p->scx.dsq_vtime += (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
}

void BPF_STRUCT_OPS(select_cpu_vtime_enable, struct task_struct *p)
{
 p->scx.dsq_vtime = vtime_now;
}

s32 BPF_STRUCT_OPS_SLEEPABLE(select_cpu_vtime_init)
{
 return scx_bpf_create_dsq(VTIME_DSQ, -1);
}

SEC(".struct_ops.link")
struct sched_ext_ops select_cpu_vtime_ops = {
 .select_cpu  = (void *) select_cpu_vtime_select_cpu,
 .dispatch  = (void *) select_cpu_vtime_dispatch,
 .running  = (void *) select_cpu_vtime_running,
 .stopping  = (void *) select_cpu_vtime_stopping,
 .enable   = (void *) select_cpu_vtime_enable,
 .init   = (void *) select_cpu_vtime_init,
 .name   = "select_cpu_vtime",
 .timeout_ms  = 1000U,
};

Messung V0.5
C=98 H=95 G=96

¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge