From: Tyrel D. <ty...@li...> - 2015-03-04 20:08:29
|
On 02/27/2015 06:29 PM, Tyrel Datwyler wrote: > The sysfs attribute /sys/kernel/mobility/migration has been present for > sometime, but never actually used by drmgr. It can be used to initiate a > migration operation in place of the existing faux ibm,supsend-me rtas call. > Further, the kernel is capable of doing the device tree update. > > We can test the "migration" attribute to determine the course of action > drmgr should take. Newer kernels will return 1 indicating the kernel > does the update after a migration. If the attribute is unreadable or > returns 0 drmgr will resort to initiating the migration via rtas, and > communicate the post mobility device tree update through the > /proc/ppc64/ofdt interface to the kernel. > > Signed-off-by: Tyrel Datwyler <ty...@li...> Nathan, Hold off on pulling this patch. The corresponding kernel patch got some push back, and mpe has asked me to change the interface to test if in kernel migration is working to something like "/sys/kernel/mobility/api_version". -Tyrel > --- > src/drmgr/drmig_chrp_pmig.c | 47 +++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 41 insertions(+), 6 deletions(-) > > diff --git a/src/drmgr/drmig_chrp_pmig.c b/src/drmgr/drmig_chrp_pmig.c > index a7c1ec5..9c50df8 100644 > --- a/src/drmgr/drmig_chrp_pmig.c > +++ b/src/drmgr/drmig_chrp_pmig.c > @@ -28,6 +28,7 @@ struct pmap_struct { > }; > > #define SYSFS_HIBERNATION_FILE "/sys/devices/system/power/hibernate" > +#define SYSFS_MIGRATION_FILE "/sys/kernel/mobility/migration" > > static struct pmap_struct *plist; > static int action = 0; > @@ -559,11 +560,45 @@ valid_pmig_options(struct options *opts) > > int do_migration(uint64_t stream_val) > { > - int rc; > + int rc, fd; > + int kern_mobility = 0; > + char buf[64]; > + > + /* If the kernel can also do the device tree update we should let the kernel do all the work. > + Check if sysfs migration file is readable and returns 1. Otherwise, invoke suspend-me via > + rtas and we will do postmobility fixup ourself. */ > + rc = get_int_attribute(SYSFS_MIGRATION_FILE, NULL, &kern_mobility, sizeof(&kern_mobility)); > + if (rc) > + say(DEBUG,"get_int_attribute returned %d for path %s\n", rc, SYSFS_MIGRATION_FILE); > + > + if (!kern_mobility) { > + say(DEBUG, "about to issue ibm,suspend-me(%llx)\n", stream_val); > + rc = rtas_suspend_me(stream_val); > + say(DEBUG, "ibm,suspend-me() returned %d\n", rc); > + } else { > + sprintf(buf, "0x%llx\n", stream_val); > + > + fd = open(SYSFS_MIGRATION_FILE, O_WRONLY); > + if (fd == -1) { > + say(ERROR, "Could not open \"%s\" to initiate migration, " > + "%m\n", SYSFS_MIGRATION_FILE); > + return -1; > + } > + > + say(DEBUG, "Initiating migration via %s with %s\n", > + SYSFS_MIGRATION_FILE, buf); > + > + rc = write(fd, buf, strlen(buf)); > + if (rc < 0) { > + say(DEBUG, "Write to migration file failed with rc: %d\n", rc); > + rc = errno; > + } else if (rc > 0) > + rc = 0; > + > + close(fd); > + say(DEBUG, "Kernel migration returned %d\n", rc); > + } > > - say(DEBUG, "about to issue ibm,suspend-me(%llx)\n", stream_val); > - rc = rtas_suspend_me(stream_val); > - say(DEBUG, "ibm,suspend-me() returned %d\n", rc); > return rc; > } > > @@ -604,9 +639,9 @@ void post_mobility_update(int action) > char *path; > > if (action == HIBERNATE) > - path = "/sys/devices/system/power/hibernate"; > + path = SYSFS_HIBERNATION_FILE; > else > - path = "/sys/kernel/mobility/migrate"; > + path = SYSFS_MIGRATION_FILE; > > /* kernel will return 0 or sysfs attribute will be unreadable if drmgr > needs to perform a device tree update */ > |