Control: tag -1 fixed-upstream patch On Mon, 09 Dec 2024 08:42:14 +0000 Victor Seva <linuxman...@torreviejawireless.org> wrote: > forwarded 1089503 https://github.com/sipwise/rtpengine/issues/1882
Upstream fixed it in the following commit https://github.com/sipwise/rtpengine/commit/6b3f3b9698ed9670fedccd0db5f595d1c0db917e And also released 12.5.1.18+0~mr12.5.1.18 which contains that fix. I've also added the above mentioned commit to ``debian/patches`` and that made Salsa's CI autopkgtest job succeed, while it failed without it. I've attached the patch that I used for that. src: https://salsa.debian.org/diederik/rtpengine/-/commits/kernel-6.12-fix So that could be an alternative, but upgrading to 12.5.1.18 is probably easier and/or better. HTH, Diederik
From: Richard Fuchs <rfu...@sipwise.com> Date: Mon, 9 Dec 2024 08:16:34 -0400 Subject: MT#55283 remove debugging remnants Origin: upstream, https://github.com/sipwise/rtpengine/commit/6b3f3b9698ed9670fedccd0db5f595d1c0db917e These macros were used for development only and are not needed any more. Their names collide with an upstream patch, making compilation fail on kernels >= 6.12. Just remove these wrapper macros altogether. Change-Id: I6e154be76bfcfb650581095b169ddd58e5f464a0 --- kernel-module/xt_RTPENGINE.c | 255 ++++++++++++----------------------- 1 file changed, 87 insertions(+), 168 deletions(-) diff --git a/kernel-module/xt_RTPENGINE.c b/kernel-module/xt_RTPENGINE.c index 9961a00c..c24a33da 100644 --- a/kernel-module/xt_RTPENGINE.c +++ b/kernel-module/xt_RTPENGINE.c @@ -161,87 +161,6 @@ MODULE_ALIAS("ip6t_RTPENGINE"); #define _w_unlock(l, f) write_unlock_irqrestore(l, f) #endif -#if 0 -#define _spinlock_t spinlock_t -#define _spin_lock_init(x) spin_lock_init(x) -#define _spin_lock(x) spin_lock(x) -#define _spin_unlock(x) spin_unlock(x) -#define _rwlock_t rwlock_t -#define _rwlock_init(x) rwlock_init(x) -#define _read_lock(x) read_lock(x) -#define _read_unlock(x) read_unlock(x) -#define _write_lock(x) write_lock(x) -#define _write_unlock(x) write_unlock(x) -#else -typedef struct { - spinlock_t l; - int owner; - int line; -} _spinlock_t; -static inline void _spin_lock_init(_spinlock_t *s) { - spin_lock_init(&s->l); - s->owner = 0; -} -static inline void __spin_lock(_spinlock_t *s, int line) { - unsigned int cnt = 0; - while (true) { - if (spin_trylock(&s->l)) { - s->owner = current->pid; - s->line = line; - return; - } - cnt++; - if (cnt == 100000000) - printk(KERN_WARNING "%i stuck at %i, owned by %i at %i\n", current->pid, line, s->owner, s->line); - } -} -static inline void _spin_unlock(_spinlock_t *s) { - s->owner = 0; - spin_unlock(&s->l); -} -typedef struct { - rwlock_t l; - int owner; - int line; -} _rwlock_t; -static inline void _rwlock_init(_rwlock_t *s) { - rwlock_init(&s->l); - s->owner = 0; -} -static inline void __read_lock(_rwlock_t *s, int line) { - unsigned int cnt = 0; - while (true) { - if (read_trylock(&s->l)) - return; - cnt++; - if (cnt == 100000000) - printk(KERN_WARNING "%i stuck at %i, owned by %i at %i\n", current->pid, line, s->owner, s->line); - } -} -static inline void _read_unlock(_rwlock_t *s) { - read_unlock(&s->l); -} -static inline void __write_lock(_rwlock_t *s, int line) { - unsigned int cnt = 0; - while (true) { - if (write_trylock(&s->l)) { - s->owner = current->pid; - s->line = line; - return; - } - cnt++; - if (cnt == 100000000) - printk(KERN_WARNING "%i stuck at %i, owned by %i at %i\n", current->pid, line, s->owner, s->line); - } -} -static inline void _write_unlock(_rwlock_t *s) { - s->owner = 0; - write_unlock(&s->l); -} -#define _spin_lock(x) __spin_lock(x, __LINE__) -#define _read_lock(x) __read_lock(x, __LINE__) -#define _write_lock(x) __write_lock(x, __LINE__) -#endif @@ -525,7 +444,7 @@ struct rtpengine_table { struct global_stats_counter *rtpe_stats; - _spinlock_t player_lock; + spinlock_t player_lock; struct list_head play_streams; unsigned int num_play_streams; struct list_head packet_streams; @@ -609,7 +528,7 @@ struct play_stream_packet { struct play_stream_packets { atomic_t refcnt; - _rwlock_t lock; + rwlock_t lock; struct list_head packets; unsigned int len; unsigned int table_id; @@ -618,7 +537,7 @@ struct play_stream_packets { }; struct play_stream { - _spinlock_t lock; + spinlock_t lock; atomic_t refcnt; unsigned int idx; struct rtpengine_play_stream_info info; @@ -640,7 +559,7 @@ struct timer_thread { wait_queue_head_t queue; atomic_t shutdown; - _spinlock_t tree_lock; // XXX use mutex? + spinlock_t tree_lock; // XXX use mutex? struct btree_head64 tree; // timer entries // XXX use rbtree? bool tree_added; struct play_stream *scheduled; @@ -667,7 +586,7 @@ static struct re_auto_array calls; static struct re_auto_array streams; #ifdef KERNEL_PLAYER -static _rwlock_t media_player_lock; +static rwlock_t media_player_lock; static struct play_stream_packets **stream_packets; static unsigned int num_stream_packets; static atomic_t last_stream_packets_idx; @@ -929,7 +848,7 @@ static struct rtpengine_table *new_table(void) { INIT_LIST_HEAD(&t->packet_streams); INIT_LIST_HEAD(&t->play_streams); t->id = -1; - _spin_lock_init(&t->player_lock); + spin_lock_init(&t->player_lock); for (i = 0; i < ARRAY_SIZE(t->calls_hash); i++) { INIT_HLIST_HEAD(&t->calls_hash[i]); @@ -1158,31 +1077,31 @@ static void clear_table_player(struct rtpengine_table *t) { unsigned int idx; list_for_each_entry_safe(stream, ts, &t->play_streams, table_entry) { - _spin_lock(&stream->lock); + spin_lock(&stream->lock); stream->table_id = -1; idx = stream->idx; - _spin_unlock(&stream->lock); - _write_lock(&media_player_lock); + spin_unlock(&stream->lock); + write_lock(&media_player_lock); if (play_streams[idx] == stream) { play_streams[idx] = NULL; unref_play_stream(stream); } - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); do_stop_stream(stream); unref_play_stream(stream); } list_for_each_entry_safe(packets, tp, &t->packet_streams, table_entry) { - _write_lock(&packets->lock); + write_lock(&packets->lock); packets->table_id = -1; idx = packets->idx; - _write_unlock(&packets->lock); - _write_lock(&media_player_lock); + write_unlock(&packets->lock); + write_lock(&media_player_lock); if (stream_packets[idx] == packets) { stream_packets[idx] = NULL; unref_packet_stream(packets); } - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); unref_packet_stream(packets); } } @@ -3853,13 +3772,13 @@ static void shut_all_threads(void) { unsigned int nt; struct timer_thread **thr; - _write_lock(&media_player_lock); + write_lock(&media_player_lock); thr = timer_threads; nt = num_timer_threads; timer_threads = NULL; num_timer_threads = 0; - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); shut_threads(thr, nt); } @@ -3876,10 +3795,10 @@ static void free_packet_stream(struct play_stream_packets *stream) { if (stream->table_id != -1 && !list_empty(&stream->table_entry)) { t = get_table(stream->table_id); if (t) { - _spin_lock(&t->player_lock); + spin_lock(&t->player_lock); list_del_init(&stream->table_entry); t->num_packet_streams--; - _spin_unlock(&t->player_lock); + spin_unlock(&t->player_lock); table_put(t); } } @@ -3901,7 +3820,7 @@ static ktime_t play_stream_packet_time(struct play_stream *stream, struct play_s static void play_stream_next_packet(struct play_stream *stream) { struct play_stream_packet *packet = stream->position; struct play_stream_packets *packets = stream->packets; - _read_lock(&packets->lock); + read_lock(&packets->lock); stream->position = list_is_last(&packet->list, &packets->packets) ? NULL : list_next_entry(packet, list); if (!stream->position) { if (stream->info.repeat > 1) { @@ -3912,7 +3831,7 @@ static void play_stream_next_packet(struct play_stream *stream) { stream->info.seq += packet->seq + 1; } } - _read_unlock(&packets->lock); + read_unlock(&packets->lock); } // stream must be locked, started, and non-empty @@ -3943,7 +3862,7 @@ static void play_stream_schedule_packet_to_thread(struct play_stream *stream, st //printk(KERN_WARNING "scheduling packet %u on thread %u\n", packet->seq, tt->idx); //printk(KERN_WARNING "scheduling stream %p on thread %p (sleeper %i)\n", stream, tt, sleeper); - _spin_lock(&tt->tree_lock); + spin_lock(&tt->tree_lock); if (reschedule && !tt->scheduled && !tt->tree_added) { // we know we are next. remember this @@ -3970,7 +3889,7 @@ static void play_stream_schedule_packet_to_thread(struct play_stream *stream, st stream->timer_thread = tt; - _spin_unlock(&tt->tree_lock); + spin_unlock(&tt->tree_lock); } // stream must be locked, started, and non-empty @@ -3982,10 +3901,10 @@ static void play_stream_schedule_packet(struct play_stream *stream) { unsigned int idx; // XXX check if already scheduled - _read_lock(&media_player_lock); + read_lock(&media_player_lock); idx = atomic_fetch_add(1, &last_timer_thread_idx) % num_timer_threads; tt = timer_threads[idx]; - _read_unlock(&media_player_lock); + read_unlock(&media_player_lock); play_stream_schedule_packet_to_thread(stream, tt, false); @@ -4059,7 +3978,7 @@ static int timer_worker(void *p) { //printk(KERN_WARNING "cpu %u (%p) loop enter\n", smp_processor_id(), tt); - _spin_lock(&tt->tree_lock); + spin_lock(&tt->tree_lock); // grab and remove next scheduled stream, either from predetermined entry or from tree stream = tt->scheduled; if (!stream) { @@ -4074,7 +3993,7 @@ static int timer_worker(void *p) { } tt->tree_added = false; // we're up to date before unlock - _spin_unlock(&tt->tree_lock); + spin_unlock(&tt->tree_lock); sleeptime_ns = 500000000LL; // 0.5 seconds if (stream) { @@ -4082,11 +4001,11 @@ static int timer_worker(void *p) { now = ktime_get(); - _spin_lock(&stream->lock); + spin_lock(&stream->lock); if (stream->table_id == -1) { // we've been descheduled - _spin_unlock(&stream->lock); + spin_unlock(&stream->lock); unref_play_stream(stream); continue; } @@ -4102,12 +4021,12 @@ static int timer_worker(void *p) { //printk(KERN_WARNING "cpu %u sending packet %p from stream %p now\n", //smp_processor_id(), packet, stream); - _spin_unlock(&stream->lock); + spin_unlock(&stream->lock); //printk(KERN_WARNING "cpu %u sending packet %u now\n", tt->idx, packet->seq); play_stream_send_packet(stream, packet); - _spin_lock(&stream->lock); + spin_lock(&stream->lock); if (stream->table_id != -1) play_stream_next_packet(stream); @@ -4119,25 +4038,25 @@ static int timer_worker(void *p) { if (stream->position) { play_stream_schedule_packet_to_thread(stream, tt, false); sleeptime_ns = 0; // loop and get next packet from tree - _spin_unlock(&stream->lock); + spin_unlock(&stream->lock); unref_play_stream(stream); stream = NULL; } else { // end of stream if (!stream->info.remove_at_end) - _spin_unlock(&stream->lock); + spin_unlock(&stream->lock); else { // remove it end_of_stream(stream); - _spin_unlock(&stream->lock); - _write_lock(&media_player_lock); + spin_unlock(&stream->lock); + write_lock(&media_player_lock); if (play_streams[stream->idx] == stream) { play_streams[stream->idx] = NULL; unref_play_stream(stream); } // else log error? - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); } unref_play_stream(stream); stream = NULL; @@ -4156,7 +4075,7 @@ static int timer_worker(void *p) { //tt->idx); // return packet to tree play_stream_schedule_packet_to_thread(stream, tt, true); - _spin_unlock(&stream->lock); + spin_unlock(&stream->lock); sleeptime_ns = min(sleeptime_ns, ns_diff); unref_play_stream(stream); stream = NULL; @@ -4202,7 +4121,7 @@ static struct timer_thread *launch_thread(unsigned int cpu) { kfree(tt); return ERR_PTR(ret); } - _spin_lock_init(&tt->tree_lock); + spin_lock_init(&tt->tree_lock); tt->idx = cpu; tt->task = kthread_create_on_node(timer_worker, tt, cpu_to_node(cpu), "rtpengine_%u", cpu); if (IS_ERR(tt->task)) { @@ -4226,14 +4145,14 @@ static int init_play_streams(unsigned int n_play_streams, unsigned int n_stream_ struct play_stream_packets **new_stream_packets, **old_stream_packets = NULL; unsigned int cpu; - _write_lock(&media_player_lock); + write_lock(&media_player_lock); if (num_play_streams >= n_play_streams && num_stream_packets >= n_stream_packets) goto out; need_threads = timer_threads == NULL; - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); //printk(KERN_WARNING "allocating for %u/%u -> %u/%u streams\n", //num_play_streams, n_play_streams, @@ -4267,7 +4186,7 @@ static int init_play_streams(unsigned int n_play_streams, unsigned int n_stream_ } } - _write_lock(&media_player_lock); + write_lock(&media_player_lock); // check again ret = 0; @@ -4292,7 +4211,7 @@ static int init_play_streams(unsigned int n_play_streams, unsigned int n_stream_ } out: - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); err: shut_threads(threads_new, new_num_threads); kfree(old_play_streams); @@ -4311,22 +4230,22 @@ static int get_packet_stream(struct rtpengine_table *t, unsigned int *num) { INIT_LIST_HEAD(&new_stream->packets); INIT_LIST_HEAD(&new_stream->table_entry); - _rwlock_init(&new_stream->lock); + rwlock_init(&new_stream->lock); new_stream->table_id = t->id; atomic_set(&new_stream->refcnt, 1); for (i = 0; i < num_stream_packets; i++) { - _write_lock(&media_player_lock); + write_lock(&media_player_lock); idx = atomic_fetch_add(1, &last_stream_packets_idx) % num_stream_packets; if (stream_packets[idx]) { idx = -1; - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); continue; } stream_packets[idx] = new_stream; new_stream->idx = idx; ref_packet_stream(new_stream); - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); break; } @@ -4335,13 +4254,13 @@ static int get_packet_stream(struct rtpengine_table *t, unsigned int *num) { return -EBUSY; } - _spin_lock(&t->player_lock); + spin_lock(&t->player_lock); list_add(&new_stream->table_entry, &t->packet_streams); // hand over ref new_stream = NULL; t->num_packet_streams++; // XXX race between adding to list and stop/free? - _spin_unlock(&t->player_lock); + spin_unlock(&t->player_lock); *num = idx; return 0; @@ -4377,7 +4296,7 @@ static int play_stream_packet(const struct rtpengine_play_stream_packet_info *in //printk(KERN_WARNING "new packet %p, delay %ld us\n", packet, (long int) ktime_to_us(packet->delay)); // XXX alloc skb - _read_lock(&media_player_lock); + read_lock(&media_player_lock); ret = -ERANGE; if (info->packet_stream_idx >= num_stream_packets) @@ -4388,12 +4307,12 @@ static int play_stream_packet(const struct rtpengine_play_stream_packet_info *in if (!stream) goto out; - _write_lock(&stream->lock); + write_lock(&stream->lock); if (!list_empty(&stream->packets)) { last = list_last_entry(&stream->packets, struct play_stream_packet, list); if (ktime_after(last->delay, packet->delay)) { - _write_unlock(&stream->lock); + write_unlock(&stream->lock); ret = -ELOOP; goto out; } @@ -4402,12 +4321,12 @@ static int play_stream_packet(const struct rtpengine_play_stream_packet_info *in packet->seq = stream->len; stream->len++; - _write_unlock(&stream->lock); + write_unlock(&stream->lock); packet = NULL; ret = 0; out: - _read_unlock(&media_player_lock); + read_unlock(&media_player_lock); if (packet) free_play_stream_packet(packet); return ret; @@ -4451,14 +4370,14 @@ static int play_stream(struct rtpengine_table *t, const struct rtpengine_play_st play_stream->info = *info; play_stream->table_id = t->id; atomic_set(&play_stream->refcnt, 1); - _spin_lock_init(&play_stream->lock); + spin_lock_init(&play_stream->lock); play_stream->info.stats = stats; play_stream->info.iface_stats = iface_stats; play_stream->info.ssrc_stats = ssrc_stats; ret = 0; - _read_lock(&media_player_lock); + read_lock(&media_player_lock); if (info->packet_stream_idx >= num_stream_packets) ret = -ERANGE; @@ -4470,38 +4389,38 @@ static int play_stream(struct rtpengine_table *t, const struct rtpengine_play_st ref_packet_stream(packets); } - _read_unlock(&media_player_lock); + read_unlock(&media_player_lock); if (ret) goto out; - _read_lock(&packets->lock); + read_lock(&packets->lock); ret = -ENXIO; if (list_empty(&packets->packets)) { - _read_unlock(&packets->lock); + read_unlock(&packets->lock); goto out; } play_stream->packets = packets; play_stream->position = list_first_entry(&packets->packets, struct play_stream_packet, list); - _read_unlock(&packets->lock); + read_unlock(&packets->lock); packets = NULL; // ref handed over for (i = 0; i < num_play_streams; i++) { - _write_lock(&media_player_lock); + write_lock(&media_player_lock); idx = atomic_fetch_add(1, &last_play_stream_idx) % num_play_streams; if (play_streams[idx]) { - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); idx = -1; continue; } play_streams[idx] = play_stream; ref_play_stream(play_stream); play_stream->idx = idx; - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); break; } @@ -4509,27 +4428,27 @@ static int play_stream(struct rtpengine_table *t, const struct rtpengine_play_st if (idx == -1) goto out; - _spin_lock(&t->player_lock); + spin_lock(&t->player_lock); list_add(&play_stream->table_entry, &t->play_streams); ref_play_stream(play_stream); t->num_play_streams++; // XXX race between adding to list and stop/free? - _spin_unlock(&t->player_lock); + spin_unlock(&t->player_lock); - _spin_lock(&play_stream->lock); + spin_lock(&play_stream->lock); play_stream->start_time = ktime_get(); crypto_context_init(&play_stream->encrypt, &info->encrypt); ret = gen_rtp_session_keys(&play_stream->encrypt, &info->encrypt); if (ret) { - _spin_unlock(&play_stream->lock); + spin_unlock(&play_stream->lock); goto out; } //printk(KERN_WARNING "start time %ld us\n", (long int) ktime_to_us(play_stream->start_time)); play_stream_schedule_packet(play_stream); - _spin_unlock(&play_stream->lock); + spin_unlock(&play_stream->lock); *num = idx; ret = 0; @@ -4550,10 +4469,10 @@ static void end_of_stream(struct play_stream *stream) { t = get_table(stream->table_id); if (t) { //printk(KERN_WARNING "removing stream %p from table\n", stream); - _spin_lock(&t->player_lock); + spin_lock(&t->player_lock); list_del_init(&stream->table_entry); t->num_play_streams--; - _spin_unlock(&t->player_lock); + spin_unlock(&t->player_lock); table_put(t); unref_play_stream(stream); } @@ -4568,7 +4487,7 @@ static void do_stop_stream(struct play_stream *stream) { //printk(KERN_WARNING "stop stream %p\n", stream); - _spin_lock(&stream->lock); + spin_lock(&stream->lock); end_of_stream(stream); @@ -4576,7 +4495,7 @@ static void do_stop_stream(struct play_stream *stream) { stream->timer_thread = NULL; if (tt) { - _spin_lock(&tt->tree_lock); + spin_lock(&tt->tree_lock); if (tt->scheduled == stream) { //printk(KERN_WARNING "stream %p was scheduled\n", stream); @@ -4595,10 +4514,10 @@ static void do_stop_stream(struct play_stream *stream) { } } - _spin_unlock(&tt->tree_lock); + spin_unlock(&tt->tree_lock); } - _spin_unlock(&stream->lock); + spin_unlock(&stream->lock); } static int stop_stream(struct rtpengine_table *t, unsigned int num) { @@ -4607,7 +4526,7 @@ static int stop_stream(struct rtpengine_table *t, unsigned int num) { ret = 0; - _write_lock(&media_player_lock); + write_lock(&media_player_lock); if (num >= num_play_streams) ret = -ERANGE; @@ -4619,7 +4538,7 @@ static int stop_stream(struct rtpengine_table *t, unsigned int num) { play_streams[num] = NULL;; } - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); if (ret) return ret; @@ -4627,14 +4546,14 @@ static int stop_stream(struct rtpengine_table *t, unsigned int num) { do_stop_stream(stream); // check if stream was released, wait if it wasn't - _spin_lock(&stream->lock); + spin_lock(&stream->lock); while (stream->timer_thread) { - _spin_unlock(&stream->lock); + spin_unlock(&stream->lock); cpu_relax(); schedule(); - _spin_lock(&stream->lock); + spin_lock(&stream->lock); } - _spin_unlock(&stream->lock); + spin_unlock(&stream->lock); unref_play_stream(stream); @@ -4645,7 +4564,7 @@ static int cmd_free_packet_stream(struct rtpengine_table *t, unsigned int idx) { struct play_stream_packets *stream = NULL; int ret; - _write_lock(&media_player_lock); + write_lock(&media_player_lock); ret = -ERANGE; if (idx >= num_stream_packets) @@ -4662,30 +4581,30 @@ static int cmd_free_packet_stream(struct rtpengine_table *t, unsigned int idx) { ret = 0; out: - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); if (!stream) return ret; - _write_lock(&stream->lock); + write_lock(&stream->lock); idx = stream->idx; stream->table_id = -1; - _write_unlock(&stream->lock); + write_unlock(&stream->lock); if (idx != -1) { - _write_lock(&media_player_lock); + write_lock(&media_player_lock); if (stream_packets[idx] == stream) { stream_packets[idx] = NULL; unref_packet_stream(stream); } - _write_unlock(&media_player_lock); + write_unlock(&media_player_lock); } if (!list_empty(&stream->table_entry)) { - _spin_lock(&t->player_lock); + spin_lock(&t->player_lock); list_del_init(&stream->table_entry); t->num_packet_streams--; - _spin_unlock(&t->player_lock); + spin_unlock(&t->player_lock); unref_packet_stream(stream); } @@ -6724,7 +6643,7 @@ static int __init init(void) { goto fail; #ifdef KERNEL_PLAYER - _rwlock_init(&media_player_lock); + rwlock_init(&media_player_lock); #endif return 0; -- 2.45.2
signature.asc
Description: This is a digitally signed message part.