mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
sched/paging: Fix error: variable 'result' set but not used
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
+60
-54
@@ -72,7 +72,8 @@ pid_t g_pgworker;
|
|||||||
|
|
||||||
/* The page fill worker thread maintains a static variable called g_pftcb.
|
/* The page fill worker thread maintains a static variable called g_pftcb.
|
||||||
* If no fill is in progress, g_pftcb will be NULL. Otherwise, g_pftcb will
|
* If no fill is in progress, g_pftcb will be NULL. Otherwise, g_pftcb will
|
||||||
* point to the TCB of the task which is receiving the fill that is in progress.
|
* point to the TCB of the task which is receiving the fill that is in
|
||||||
|
* progress.
|
||||||
*
|
*
|
||||||
* NOTE: I think that this is the only state in which a TCB does not reside
|
* NOTE: I think that this is the only state in which a TCB does not reside
|
||||||
* in some list. Here is it in limbo, outside of the normally queuing while
|
* in some list. Here is it in limbo, outside of the normally queuing while
|
||||||
@@ -230,23 +231,24 @@ static void pg_callback(FAR struct tcb_s *tcb, int result)
|
|||||||
|
|
||||||
static inline bool pg_dequeue(void)
|
static inline bool pg_dequeue(void)
|
||||||
{
|
{
|
||||||
/* Loop until either (1) the TCB of a task that requires a fill is found, OR
|
/* Loop until either (1) the TCB of a task that requires a fill is found,
|
||||||
* (2) the g_watingforfill list becomes empty.
|
* OR (2) the g_watingforfill list becomes empty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Remove the TCB from the head of the list (if any) */
|
/* Remove the TCB from the head of the list (if any) */
|
||||||
|
|
||||||
g_pftcb = (FAR struct tcb_s *)dq_remfirst((dq_queue_t *)&g_waitingforfill);
|
g_pftcb = (FAR struct tcb_s *)
|
||||||
|
dq_remfirst((FAR dq_queue_t *)&g_waitingforfill);
|
||||||
pginfo("g_pftcb: %p\n", g_pftcb);
|
pginfo("g_pftcb: %p\n", g_pftcb);
|
||||||
if (g_pftcb != NULL)
|
if (g_pftcb != NULL)
|
||||||
{
|
{
|
||||||
/* Call the architecture-specific function up_checkmapping() to see if
|
/* Call the architecture-specific function up_checkmapping() to see
|
||||||
* the page fill still needs to be performed. In certain conditions,
|
* if the page fill still needs to be performed. In certain
|
||||||
* the page fault may occur on several threads for the same page and
|
* conditions, the page fault may occur on several threads for the
|
||||||
* be queues multiple times. In this corner case, the blocked task will
|
* same page and be queues multiple times. In this corner case, the
|
||||||
* simply be restarted.
|
* blocked task will simply be restarted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!up_checkmapping(g_pftcb))
|
if (!up_checkmapping(g_pftcb))
|
||||||
@@ -352,10 +354,10 @@ static inline bool pg_startfill(void)
|
|||||||
|
|
||||||
if (pg_dequeue())
|
if (pg_dequeue())
|
||||||
{
|
{
|
||||||
/* Call up_allocpage(tcb, &vpage). This architecture-specific function will
|
/* Call up_allocpage(tcb, &vpage). This architecture-specific function
|
||||||
* set aside page in memory and map to virtual address (vpage). If all
|
* will set aside page in memory and map to virtual address (vpage). If
|
||||||
* available pages are in-use (the typical case), this function will select
|
* all available pages are in-use (the typical case), this function
|
||||||
* a page in-use, un-map it, and make it available.
|
* will select a page in-use, un-map it, and make it available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pginfo("Call up_allocpage(%p)\n", g_pftcb);
|
pginfo("Call up_allocpage(%p)\n", g_pftcb);
|
||||||
@@ -363,29 +365,30 @@ static inline bool pg_startfill(void)
|
|||||||
DEBUGASSERT(result == OK);
|
DEBUGASSERT(result == OK);
|
||||||
|
|
||||||
/* Start the fill. The exact way that the fill is started depends upon
|
/* Start the fill. The exact way that the fill is started depends upon
|
||||||
* the nature of the architecture-specific up_fillpage() function -- Is it
|
* the nature of the architecture-specific up_fillpage() function -- Is
|
||||||
* a blocking or a non-blocking call?
|
* it a blocking or a non-blocking call?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_PAGING_BLOCKINGFILL
|
#ifdef CONFIG_PAGING_BLOCKINGFILL
|
||||||
/* If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is blocking
|
/* If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is
|
||||||
* call. In this case, up_fillpage() will accept only (1) a reference to
|
* blocking call. In this case, up_fillpage() will accept only (1) a
|
||||||
* the TCB that requires the fill. Architecture-specific context information
|
* reference to the TCB that requires the fill. Architecture-specific
|
||||||
* within the TCB will be sufficient to perform the fill. And (2) the
|
* context information within the TCB will be sufficient to perform the
|
||||||
* (virtual) address of the allocated page to be filled. The resulting
|
* fill. And (2) the (virtual) address of the allocated page to be
|
||||||
* status of the fill will be provided by return value from up_fillpage().
|
* filled. The resulting status of the fill will be provided by return
|
||||||
|
* value from up_fillpage().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pginfo("Call up_fillpage(%p)\n", g_pftcb);
|
pginfo("Call up_fillpage(%p)\n", g_pftcb);
|
||||||
result = up_fillpage(g_pftcb, vpage);
|
result = up_fillpage(g_pftcb, vpage);
|
||||||
DEBUGASSERT(result == OK);
|
DEBUGASSERT(result == OK);
|
||||||
#else
|
#else
|
||||||
/* If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is non-blocking
|
/* If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is non-
|
||||||
* call. In this case up_fillpage() will accept an additional argument: The
|
* blocking call. In this case up_fillpage() will accept an additional
|
||||||
* page fill worker thread will provide a callback function, pg_callback.
|
* argument: The page fill worker thread will provide a callback
|
||||||
*
|
* function, pg_callback.
|
||||||
* Calling up_fillpage will start an asynchronous page fill. pg_callback
|
* up_fillpage will start an asynchronous page fill. pg_callback
|
||||||
* ill be called when the page fill is finished (or an error occurs). This
|
* will be called when the page fill is finished (or an error occurs).
|
||||||
* This callback will probably from interrupt level.
|
* This callback will probably from interrupt level.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -393,23 +396,24 @@ static inline bool pg_startfill(void)
|
|||||||
result = up_fillpage(g_pftcb, vpage, pg_callback);
|
result = up_fillpage(g_pftcb, vpage, pg_callback);
|
||||||
DEBUGASSERT(result == OK);
|
DEBUGASSERT(result == OK);
|
||||||
|
|
||||||
/* Save the time that the fill was started. These will be used to check for
|
/* Save the time that the fill was started. These will be used to
|
||||||
* timeouts.
|
* check for timeouts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_PAGING_TIMEOUT_TICKS
|
#ifdef CONFIG_PAGING_TIMEOUT_TICKS
|
||||||
g_starttime = clock_systimer();
|
g_starttime = clock_systimer();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Return and wait to be signaled for the next event -- the fill completion
|
/* Return and wait to be signaled for the next event -- the fill
|
||||||
* event. While the fill is in progress, other tasks may execute. If
|
* completion event. While the fill is in progress, other tasks may
|
||||||
* another page fault occurs during this time, the faulting task will be
|
* execute. If another page fault occurs during this time, the faulting
|
||||||
* blocked, its TCB will be added (in priority order) to g_waitingforfill
|
* task will be blocked, its TCB will be added (in priority order) to
|
||||||
* and the priority of the page worker task may be boosted. But no action
|
* g_waitingforfill and the priority of the page worker task may be
|
||||||
* will be taken until the current page fill completes. NOTE: The IDLE task
|
* boosted. But no action will be taken until the current page fill
|
||||||
* must also be fully locked in memory. The IDLE task cannot be blocked. It
|
* completes. NOTE: The IDLE task must also be fully locked in memory.
|
||||||
* the case where all tasks are blocked waiting for a page fill, the IDLE
|
* The IDLE task cannot be blocked. It the case where all tasks are
|
||||||
* task must still be available to run.
|
* blocked waiting for a page fill, the IDLE task must still be
|
||||||
|
* available to run.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif /* CONFIG_PAGING_BLOCKINGFILL */
|
#endif /* CONFIG_PAGING_BLOCKINGFILL */
|
||||||
@@ -418,6 +422,7 @@ static inline bool pg_startfill(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pginfo("Queue empty\n");
|
pginfo("Queue empty\n");
|
||||||
|
UNUSED(result);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,8 +523,8 @@ static inline void pg_fillcomplete(void)
|
|||||||
|
|
||||||
int pg_worker(int argc, char *argv[])
|
int pg_worker(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
/* Loop forever -- Notice that interrupts will be disabled at all times that
|
/* Loop forever -- Notice that interrupts will be disabled at all times
|
||||||
* this thread runs. That is so that we can't lose signals or have
|
* that this thread runs. That is so that we can't lose signals or have
|
||||||
* asynchronous page faults.
|
* asynchronous page faults.
|
||||||
*
|
*
|
||||||
* All interrupt logic as well as all page fill worker thread logic must
|
* All interrupt logic as well as all page fill worker thread logic must
|
||||||
@@ -532,10 +537,10 @@ int pg_worker(int argc, char *argv[])
|
|||||||
up_irq_save();
|
up_irq_save();
|
||||||
for (; ; )
|
for (; ; )
|
||||||
{
|
{
|
||||||
/* Wait awhile. We will wait here until either the configurable timeout
|
/* Wait awhile. We will wait here until either the configurable
|
||||||
* elapses or until we are awakened by a signal (which terminates the
|
* timeout elapses or until we are awakened by a signal (which
|
||||||
* nxsig_usleep with an EINTR error). Note that interrupts will be re-
|
* terminates the nxsig_usleep with an EINTR error). Note that
|
||||||
* enabled while this task sleeps.
|
* interrupts will be re- enabled while this task sleeps.
|
||||||
*
|
*
|
||||||
* The timeout is a failsafe that will handle any cases where a single
|
* The timeout is a failsafe that will handle any cases where a single
|
||||||
* is lost (that would really be a bug and shouldn't happen!) and also
|
* is lost (that would really be a bug and shouldn't happen!) and also
|
||||||
@@ -544,7 +549,7 @@ int pg_worker(int argc, char *argv[])
|
|||||||
|
|
||||||
nxsig_usleep(CONFIG_PAGING_WORKPERIOD);
|
nxsig_usleep(CONFIG_PAGING_WORKPERIOD);
|
||||||
|
|
||||||
/* The page fill worker thread will be awakened on one of three conditions:
|
/* The page fill worker thread will be awakened on one of 3 conditions:
|
||||||
*
|
*
|
||||||
* - When signaled by pg_miss(), the page fill worker thread will be
|
* - When signaled by pg_miss(), the page fill worker thread will be
|
||||||
* awakened,
|
* awakened,
|
||||||
@@ -556,15 +561,16 @@ int pg_worker(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONFIG_PAGING_BLOCKINGFILL
|
#ifndef CONFIG_PAGING_BLOCKINGFILL
|
||||||
/* For the non-blocking up_fillpage(), the page fill worker thread will detect
|
/* For the non-blocking up_fillpage(), the page fill worker thread will
|
||||||
* that the page fill is complete when it is awakened with g_pftcb non-NULL
|
* detect that the page fill is complete when it is awakened with
|
||||||
* and fill completion status from pg_callback.
|
* g_pftcb non-NULL and fill completion status from pg_callback.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (g_pftcb != NULL)
|
if (g_pftcb != NULL)
|
||||||
{
|
{
|
||||||
/* If it is a real page fill completion event, then the result of the page
|
/* If it is a real page fill completion event, then the result of
|
||||||
* fill will be in g_fillresult and will not be equal to -EBUSY.
|
* the page fill will be in g_fillresult and will not be equal to
|
||||||
|
* -EBUSY.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (g_fillresult != -EBUSY)
|
if (g_fillresult != -EBUSY)
|
||||||
@@ -573,8 +579,8 @@ int pg_worker(int argc, char *argv[])
|
|||||||
|
|
||||||
DEBUGASSERT(g_fillresult == OK);
|
DEBUGASSERT(g_fillresult == OK);
|
||||||
|
|
||||||
/* Handle the successful page fill complete event by restarting the
|
/* Handle the successful page fill complete event by restarting
|
||||||
* task that was blocked waiting for this page fill.
|
* the task that was blocked waiting for this page fill.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pginfo("Restarting TCB: %p\n", g_pftcb);
|
pginfo("Restarting TCB: %p\n", g_pftcb);
|
||||||
@@ -598,8 +604,8 @@ int pg_worker(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If a configurable timeout period expires with no page fill completion
|
/* If a configurable timeout period expires with no page fill
|
||||||
* event, then declare a failure.
|
* completion event, then declare a failure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_PAGING_TIMEOUT_TICKS
|
#ifdef CONFIG_PAGING_TIMEOUT_TICKS
|
||||||
|
|||||||
Reference in New Issue
Block a user