def test_frames_and_record_result(self, frame_stati, allowed_sources): pfns = [frame_status.pfn for frame_status in frame_stati] # print "TO TEST: ", pfns status_by_pfn = dict([(frame_status.pfn, frame_status) for frame_status in frame_stati]) results = self._claim_pfns(pfns, allowed_sources) num_frames_claimed = 0 claimed_physaddr = [] for frame in results: if frame.pfn in status_by_pfn: if frame.is_claimed(): num_frames_claimed += 1 claimed_physaddr.append(frame.pfn * physmem.PAGE_SIZE) # map all claimed frames and test them together error_offsets = [] if num_frames_claimed > 0: with self.physmem_device.mmap(physmem.PAGE_SIZE * num_frames_claimed) as map: for test in self.frame_tests: error_offsets += test.test(map, 0, physmem.PAGE_SIZE * num_frames_claimed, claimed_physaddr) # create mapping from vma-pagenumber to error offset errors_by_page = dict([(ofs / physmem.PAGE_SIZE, ofs) for ofs in error_offsets]) for frame in results: if frame.pfn in status_by_pfn: frame_status = status_by_pfn[frame.pfn] frame_status.last_claiming_attempt = self.timestamping.timestamp() if frame.is_claimed(): frame_status.last_claiming_time_jiffies = frame.allocation_cost_jiffies frame_status.last_successful_claiming_method = frame.actual_source if frame.vma_offset_of_first_byte / physmem.PAGE_SIZE in errors_by_page: # page is in error list frame_status.num_errors += 1 frame_status.last_failed_test = self.timestamping.timestamp() self.physmem_device.mark_pfn_bad(frame.pfn) self._report_bad_frame(frame.pfn) else: # page is not in error list frame_status.num_errors = 0 frame_status.last_successful_test = self.timestamping.timestamp() self._report_good_frame(frame.pfn) else: # Hmm, better luck next time self._report_not_aquired_frame(frame_status.pfn) return num_frames_claimed
def test_frames_and_record_result(self,frame_stati, allowed_sources): pfns = [frame_status.pfn for frame_status in frame_stati] status_by_pfn = dict([ (frame_status.pfn, frame_status) for frame_status in frame_stati]) results = self._claim_pfns(pfns, allowed_sources) num_frames_claimed = 0 for frame in results: if frame.pfn in status_by_pfn: if frame.is_claimed(): num_frames_claimed += 1 for frame in results: if frame.pfn in status_by_pfn: frame_status = status_by_pfn[frame.pfn] frame_status.last_claiming_attempt = self.timestamping.timestamp() if frame.is_claimed(): frame_status.last_claiming_time_jiffies = frame.allocation_cost_jiffies frame_status.last_successfull_claiming_method = frame.actual_source is_ok = False with self.physmem_device.mmap(physmem.PAGE_SIZE * num_frames_claimed) as map: # It is better to handle bad frames after they are unmapped is_ok = self.frame_test.test(map,frame.vma_offset_of_first_byte ,physmem.PAGE_SIZE) if is_ok: frame_status.has_errors = 0 frame_status.last_successfull_test = self.timestamping.timestamp() self._report_good_frame(frame.pfn) else: frame_status.num_errors += 1 self.physmem_device.mark_pfn_bad(frame.pfn) self._report_bad_frame(frame.pfn) else: # Hmm, better luck next time self._report_not_aquired_frame(frame_status.pfn)
def test_frame_and_record_result(self, frame_status, allowed_sources): pfns = [frame_status.pfn] results = self._claim_pfns(pfns, allowed_sources) for frame in results: # I know that there is only one frame in the result. Anyway, looping is # cleaner if frame_status.pfn == frame.pfn: frame_status.last_claiming_attempt = self._timestamp() if frame.is_claimed(): # I know that there is only one frame in the result. Anyway, looping is # cleaner if frame_status.pfn != frame.pfn: raise RuntimeError( "Unexpected mismatch of frames: wanted pfn %d, got pfn %d", (frame_status.pfn, frame.pfn)) frame_status.last_claiming_time_jiffies = frame.allocation_cost_jiffies frame_status.last_successful_claiming_method = frame.actual_source is_ok = False with self.physmem_device.mmap(physmem.PAGE_SIZE) as map: # It is better to handle bad frames after they are unmapped for test in self.frame_tests: is_ok = (test.test_single(map, 0, frame.pfn * 4096) == None) if is_ok: frame_status.has_errors = 0 frame_status.last_successful_test = self._timestamp() self._report_good_frame(frame.pfn) else: frame_status.num_errors += 1 self.physmem_device.mark_pfn_bad(frame.pfn) self._report_bad_frame(frame.pfn) else: # Hmm, better luck next time self._report_not_aquired_frame(frame_status.pfn)
def test_frame_and_record_result(self, frame_status, allowed_sources): pfns = [frame_status.pfn] results = self._claim_pfns(pfns, allowed_sources) for frame in results: # I know that there is only one frame in the result. Anyway, looping is # cleaner if frame_status.pfn == frame.pfn: frame_status.last_claiming_attempt = self._timestamp() if frame.is_claimed(): # I know that there is only one frame in the result. Anyway, looping is # cleaner if frame_status.pfn != frame.pfn: raise RuntimeError( "Unexpected mismatch of frames: wanted pfn %d, got pfn %d", (frame_status.pfn, frame.pfn) ) frame_status.last_claiming_time_jiffies = frame.allocation_cost_jiffies frame_status.last_successfull_claiming_method = frame.actual_source is_ok = False with self.physmem_device.mmap(physmem.PAGE_SIZE) as map: # It is better to handle bad frames after they are unmapped is_ok = self.frame_test.test(map, 0, physmem.PAGE_SIZE) if is_ok: frame_status.has_errors = 0 frame_status.last_successfull_test = self._timestamp() self._report_good_frame(frame.pfn) else: frame_status.num_errors += 1 self.physmem_device.mark_pfn_bad(frame.pfn) self._report_bad_frame(frame.pfn) else: # Hmm, better luck next time self._report_not_aquired_frame(frame_status.pfn)
def test_frames_and_record_result(self,frame_stati, allowed_sources): # extract list of PFNs to test pfns = [frame_status.pfn for frame_status in frame_stati] # print "TO TEST: ", pfns # create dict that maps a PFN to its frame_status instance status_by_pfn = dict([ (frame_status.pfn, frame_status) for frame_status in frame_stati]) # attempt to claim results = self._claim_pfns(pfns, allowed_sources) num_frames_claimed = 0 claimed_physaddr = [] # gather list of claimed frames for frame in results: if frame.pfn in status_by_pfn: if frame.is_claimed(): num_frames_claimed += 1 claimed_physaddr.append(frame.pfn * physmem.PAGE_SIZE) # map all claimed frames and test them together error_offsets = [] if num_frames_claimed > 0: with self.physmem_device.mmap(physmem.PAGE_SIZE * num_frames_claimed) as map: for test in self.frame_tests: error_offsets += test.test(map, 0, physmem.PAGE_SIZE * num_frames_claimed, claimed_physaddr) # create mapping from vma-pagenumber to error offset errors_by_page = dict([ (ofs/physmem.PAGE_SIZE, ofs) for ofs in error_offsets]) # iterate over claimer output list (i.e. all frames) and update their status for frame in results: if frame.pfn in status_by_pfn: # PFN was part of the original list of frames to test frame_status = status_by_pfn[frame.pfn] frame_status.last_claiming_attempt = self.timestamping.timestamp() if frame.is_claimed(): frame_status.last_claiming_time_jiffies = frame.allocation_cost_jiffies frame_status.last_successful_claiming_method = frame.actual_source if frame.vma_offset_of_first_byte/physmem.PAGE_SIZE in errors_by_page: # page is in error list frame_status.num_errors += 1 frame_status.last_failed_test = self.timestamping.timestamp() self.physmem_device.mark_pfn_bad(frame.pfn) self._report_bad_frame(frame.pfn) else: # page is not in error list frame_status.num_errors = 0 frame_status.last_successful_test = self.timestamping.timestamp() self._report_good_frame(frame.pfn) else: # PFN wasn't in the list # The pfn field in a frame_status is set to 0 by the kernel module, # so we'd have to check the original request entry at the same index # to figure out which PFN failed here. The only time the "if frame.is_claimed()" # in the block above will not be true is when PFN 0 is part of # the list of pages passed as frame_stati and in that case a failure of # any PFN in the list will be interpreted as a failure to claim PFN 0. # # Original comment: # Hmm, better luck next time self._report_not_aquired_frame(frame_status.pfn) return num_frames_claimed
def test_frames_and_record_result(self, frame_stati, allowed_sources): pfns = [frame_status.pfn for frame_status in frame_stati] # print "TO TEST: ", pfns status_by_pfn = dict([(frame_status.pfn, frame_status) for frame_status in frame_stati]) results = self._claim_pfns(pfns, allowed_sources) num_frames_claimed = 0 claimed_physaddr = [] for frame in results: if frame.pfn in status_by_pfn: if frame.is_claimed(): num_frames_claimed += 1 claimed_physaddr.append(frame.pfn * physmem.PAGE_SIZE) # map all claimed frames and test them together error_offsets = [] if num_frames_claimed > 0: with self.physmem_device.mmap(physmem.PAGE_SIZE * num_frames_claimed) as map: for test in self.frame_tests: error_offsets += test.test( map, 0, physmem.PAGE_SIZE * num_frames_claimed, claimed_physaddr) # create mapping from vma-pagenumber to error offset errors_by_page = dict([(ofs / physmem.PAGE_SIZE, ofs) for ofs in error_offsets]) for frame in results: if frame.pfn in status_by_pfn: frame_status = status_by_pfn[frame.pfn] frame_status.last_claiming_attempt = self.timestamping.timestamp( ) if frame.is_claimed(): frame_status.last_claiming_time_jiffies = frame.allocation_cost_jiffies frame_status.last_successful_claiming_method = frame.actual_source if frame.vma_offset_of_first_byte / physmem.PAGE_SIZE in errors_by_page: # page is in error list frame_status.num_errors += 1 frame_status.last_failed_test = self.timestamping.timestamp( ) self.physmem_device.mark_pfn_bad(frame.pfn) self._report_bad_frame(frame.pfn) else: # page is not in error list frame_status.num_errors = 0 frame_status.last_successful_test = self.timestamping.timestamp( ) self._report_good_frame(frame.pfn) else: # Hmm, better luck next time self._report_not_aquired_frame(frame_status.pfn) return num_frames_claimed