コード例 #1
0
/*
 * Free all frame-stati in session->frame_stati  and
 * reset the session so, that the frame-stati-part is
 * 'Unconfigured'
 * Claimed pages in the frame-stati are freed.
 *
 *  The session lock must be held, when calling this function.
 */
void free_page_stati(struct phys_mem_session* session) {


    if (session->frame_stati) {
        if (session->num_frame_stati) {
            size_t i;

            for (i = 0; i < session->num_frame_stati; i++) {
                struct page* p = session->frame_stati[i].page;
                if (p) {
                    session->frame_stati[i].page = NULL;

                    if (page_count(p)) {
                        printk(KERN_DEBUG "Session %llu: Freeing page #%lu @%lu with page_count %u\n", session->session_id, page_to_pfn(p), i, page_count(p));
                        __free_pages(p, 0);
                    } else {
                        printk(KERN_WARNING "Session %llu: NOT freeing page #%lu @%lu with page_count %u\n", session->session_id, page_to_pfn(p), i, page_count(p));
                    }
                }
            }
        }
        SESSION_FREE_FRAME_STATI(session->frame_stati);
    }
    session->num_frame_stati = 0;
    session->frame_stati = NULL;
}
コード例 #2
0
ファイル: main.c プロジェクト: wangxiaoq/MEI
/*
 * Free all frame-stati in session->frame_stati  and
 * reset the session so, that the frame-stati-part is
 * 'Unconfigured'
 * Claimed pages in the frame-stati are freed.
 *
 *  The session lock must be held, when calling this function.
 */
void free_page_stati(struct phys_mem_session* session) {
    if (session->frame_stati) {
        if (session->num_frame_stati) {
            size_t i;

            for (i = 0; i < session->num_frame_stati; i++) {
                struct page* p = session->frame_stati[i].page;
                if (p) {
                    session->frame_stati[i].page = NULL;

                    // FIXME: Use a pointer to unclaim-method
                    if (session->frame_stati[i].actual_source == SOURCE_HOTPLUG_CLAIM) {
                      unclaim_pages_via_hotplug(p);
                    } else
                      if (page_count(p)) {
#if 0
                        printk(KERN_DEBUG "Session %llu: Freeing page 0x%08lx @%lu with page_count %u\n", session->session_id, page_to_pfn(p), i, page_count(p));
#endif
                        __free_pages(p, 0);
                    } else {
                        printk(KERN_WARNING "Session %llu: NOT freeing page 0x%08lx @%lu with page_count %u\n", session->session_id, page_to_pfn(p), i, page_count(p));
                    }
                }
            }
        }
        SESSION_FREE_FRAME_STATI(session->frame_stati);
    }
    session->num_frame_stati = 0;
    session->frame_stati = NULL;
}