source: trunk/kernel/syscalls/sys_trace.c @ 603

Last change on this file since 603 was 566, checked in by alain, 6 years ago

Complete restructuration of kernel locks.

File size: 2.8 KB
RevLine 
[1]1/*
[443]2 * sys_trace.c - activate / desactivate the context switches trace for a given core
[1]3 *
[443]4 * Author    Alain Greiner (c) (2016,2017,2018)
[1]5 *
[23]6 * Copyright (c) UPMC Sorbonne Universites
[1]7 *
[23]8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
[1]11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
[23]14 * ALMOS-MKH is distributed in the hope that it will be useful, but
[1]15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
[23]20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
[1]21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
[457]24#include <hal_kernel_types.h>
[23]25#include <hal_special.h>
26#include <printk.h>
[1]27#include <thread.h>
28#include <errno.h>
[443]29#include <shared_syscalls.h>
[23]30#include <syscalls.h>
[1]31
[443]32///////////////////////////////
33int sys_trace( bool_t   active,
34               cxy_t    cxy,
35               lid_t    lid )
[1]36{
[443]37    uint32_t    ncores;
[1]38
[443]39    thread_t  * this    = CURRENT_THREAD;
40    process_t * process = this->process;
41
42#if DEBUG_SYS_TRACE
43uint64_t    tm_start;
44uint64_t    tm_end;
45tm_start = hal_get_cycles();
46if( DEBUG_SYS_TRACE < tm_start )
47printk("\n[DBG] %s : thread %d enter / process %x / cycle = %d\n",
48__FUNCTION__, this, this->process->pid, (uint32_t)tm_start );
49#endif
50
51    // check cluster identifier
52    if( cluster_is_undefined( cxy ) )
[23]53    {
[443]54
55#if DEBUG_SYSCALLS_ERROR
56printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n",
57__FUNCTION__ , cxy , this->trdid , process->pid );
58#endif
59        this->errno = EINVAL;
[23]60        return -1;
61    }
[1]62
[443]63    // check core local index
[566]64    ncores = hal_remote_l32( XPTR( cxy , &LOCAL_CLUSTER->cores_nr ) );
[443]65    if( lid >= ncores )
[23]66    {
[1]67
[443]68#if DEBUG_SYSCALLS_ERROR
69printk("\n[ERROR] in %s : illegal lid argument %x / thread %x / process %x\n",
70__FUNCTION__ , lid , this->trdid , process->pid );
71#endif
72        this->errno = EINVAL;
[23]73        return -1;
74    }
[1]75
[443]76    // get local pointer on target core
77    core_t * core = &LOCAL_CLUSTER->core_tbl[lid];
78
79    // get extended pointer on target scheduler trace field
80    xptr_t trace_xp = XPTR( cxy , &core->scheduler.trace );
81
[566]82    if ( active ) hal_remote_s32( trace_xp , 1 );
83    else          hal_remote_s32( trace_xp , 0 );
[443]84   
[124]85    hal_fence();
[1]86
[443]87#if DEBUG_SYS_TRACE
88tm_end = hal_get_cycles();
89if( DEBUG_SYS_TRACE < tm_end )
90printk("\n[DBG] %s : thread %x exit / process %x / cost = %d / cycle %d\n",
91__FUNCTION__, this, this->process->pid, (uint32_t)(tm_end - tm_start) , (uint32_t)tm_end );
92#endif
93
[23]94    return 0;
[1]95
[23]96}  // end sys_trace()
Note: See TracBrowser for help on using the repository browser.