Remove the return value from vcore_request_more()
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 25 Feb 2016 16:17:48 +0000 (11:17 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 May 2016 21:11:15 +0000 (17:11 -0400)
For a long time now the return value was of dubious value - you were never
really guaranteed that you were the one who executed the poke, so it was
possible for you to get a 0 back (success) but the call actually failed
under the hood.

Of course, none of the tests really had that issue.  vcore_request_* will
just panic internally on any error.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tests/old/mproctests.c
tests/old/msr_get_singlecore.c
user/parlib/include/parlib/vcore.h
user/parlib/vcore.c

index 3160b55..aacd4af 100644 (file)
@@ -27,7 +27,6 @@ static void global_tests(uint32_t vcoreid);
 int main(int argc, char** argv)
 {
        uint32_t vcoreid;
-       int retval;
        vcore_lib_init();
 
        if ((vcoreid = vcore_id())) {
@@ -53,22 +52,20 @@ int main(int argc, char** argv)
                                printf("Should not see me!!!!!!!!!!!!!!!!!!\n");
                                while(1);
                        case TEST_ONE_CORE:
-                               retval = vcore_request_more(1);
-                               printf("One core test's core0's retval: %d\n", retval);
+                               vcore_request_more(1);
+                               printf("One core test's core0 is done\n");
                                printf("Check to see it's on a worker core.\n");
                                while(1);
                        case TEST_ASK_FOR_TOO_MANY_CORES:
-                               retval = vcore_request_more(12);
-                               printf("Asked for too many, retval: %d\n", retval);
+                               vcore_request_more(12);
+                               printf("Asked for too many is done\n");
                                return 0;
                        case TEST_INCREMENTAL_CHANGES:
-                               retval = vcore_request_more(4);
+                               vcore_request_more(4);
                                break;
                        default:
-                               retval = vcore_request_more(5);
+                               vcore_request_more(5);
                }
-               if (retval)
-                       panic("failed to allocate cores!");
                printf("Should see me if you want to relocate core0's context "
                        "when moving from RUNNING_S\n");
        }
@@ -78,7 +75,7 @@ int main(int argc, char** argv)
                case TEST_YIELD_OUT_OF_ORDER:
                        udelay(10000000);
                        printf("Core 2 should have yielded, asking for another\n");
-                       retval = vcore_request_more(5);
+                       vcore_request_more(5);
                        break;
                case TEST_YIELD_0_OUT_OF_ORDER:
                        udelay(5000000);
@@ -97,7 +94,6 @@ void vcore_entry(void)
 {
        uint32_t vcoreid;
        static int first_time = 1; // used by vcore2
-       int retval;
 
        vcoreid = vcore_id();
        printf("Hello from vcore_entry in vcore %d\n", vcoreid);
@@ -109,13 +105,11 @@ void vcore_entry(void)
                                // Testing asking for less than we already have
                                udelay(1000000);
                                printf("Asking for too few:\n");
-                               retval = vcore_request_more(2);
-                               printf("Should be -EINVAL(7): %d\n", retval);
+                               vcore_request_more(2);
                                // Testing getting more while running
                                printf("Asking for more while running:\n");
                                udelay(1000000);
-                               retval = vcore_request_more(5);
-                               printf("core2's retval: %d\n", retval);
+                               vcore_request_more(5);
                                break;
                        case TEST_YIELD_OUT_OF_ORDER:
                                printf("Core %d yielding\n", vcoreid);
@@ -124,7 +118,7 @@ void vcore_entry(void)
                        case TEST_YIELD_0_OUT_OF_ORDER:
                                udelay(7500000);
                                printf("Core 0 should have yielded, asking for another\n");
-                               retval = vcore_request_more(5);
+                               vcore_request_more(5);
                }
        }
        global_tests(vcoreid);
@@ -133,7 +127,6 @@ void vcore_entry(void)
 
 static void global_tests(uint32_t vcoreid)
 {
-       int retval;
        switch (test) {
                case TEST_YIELD_ALL:
                        printf("Core %d yielding\n", vcoreid);
@@ -144,9 +137,9 @@ static void global_tests(uint32_t vcoreid)
                        if (vcoreid == 2) {
                                printf("Core %d trying to request 0/ switch to _S\n", vcoreid);
                                udelay(3000000);
-                               retval = vcore_request_more(0);
+                               vcore_request_more(0);
                                // will only see this if we are scheduled()
-                               printf("Core %d back up! (retval:%d)\n", vcoreid, retval);
+                               printf("Core %d back up!\n");
                                printf("And exiting\n");
                                exit(0);
                        } 
index 613b600..e4626a6 100644 (file)
@@ -26,7 +26,6 @@ volatile bool core1_up = FALSE;
 int main(int argc, char** argv)
 {
        uint32_t vcoreid = vcore_id();
-       int retval = 0;
 
        mcs_barrier_init(&b, max_vcores());
 
@@ -53,9 +52,7 @@ int main(int argc, char** argv)
 
        printf("Proc %d requesting another vcore\n", getpid());
        begin = read_tsc();
-       retval = vcore_request_more(1);
-       if (retval)
-               printf("Fucked!\n");
+       vcore_request_more(1);
        while (!core1_up)
                cpu_relax;
        end = read_tsc();
@@ -67,9 +64,7 @@ int main(int argc, char** argv)
        udelay(2000000);
        printf("Proc %d requesting the vcore again\n", getpid());
        begin = read_tsc();
-       retval = vcore_request_more(1);
-       if (retval)
-               printf("Fucked!\n");
+       vcore_request_more(1);
        while (!core1_up)
                cpu_relax();
        end = read_tsc();
index 0ba8c0f..feffd83 100644 (file)
@@ -53,7 +53,7 @@ static inline uint64_t vcore_account_resume_nsec(uint32_t vcoreid);
 static inline uint64_t vcore_account_total_nsec(uint32_t vcoreid);
 void vcore_lib_init(void);
 void vcore_change_to_m(void);
-int vcore_request_more(long nr_new_vcores);
+void vcore_request_more(long nr_new_vcores);
 void vcore_request_total(long nr_vcores_wanted);
 void vcore_yield(bool preempt_pending);
 void vcore_reenter(void (*entry_func)(void));
index 8b7b2c5..7e64e4b 100644 (file)
@@ -274,13 +274,10 @@ void vcore_request_total(long nr_vcores_wanted)
  *
  * So for now, this will keep the older behavior (one more than I have).  This
  * is all quite racy, so we can just guess and request a total number of vcores.
- *
- * Returns 0 always, probably panics on error.  This does not return the number
- * of cores actually granted (though some parts of the kernel do internally). */
-int vcore_request_more(long nr_new_vcores)
+ */
+void vcore_request_more(long nr_new_vcores)
 {
        vcore_request_total(nr_new_vcores + num_vcores());
-       return 0;
 }
 
 /* This can return, if you failed to yield due to a concurrent event.  Note