bionic: add __system_property_area_serial()
Adds a new _internal_ function. Provide a global serial number to
support more efficient private caching algorithms. This allows
to skip re-running the __system_property_find() call on misses until
there is a global change in the properties. This call is a read
barrier, the property data to be read following this call will be
read sequentially and up to date.
(Cherry pick from bfd65279a5)
Bug: 19544788
Change-Id: I58e6a92baa0f3e8e7b9ec79b10af6d56407dab48
			
			
This commit is contained in:
		@@ -598,6 +598,16 @@ int __system_property_area_init()
 | 
				
			|||||||
    return map_prop_area_rw();
 | 
					    return map_prop_area_rw();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					unsigned int __system_property_area_serial()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    prop_area *pa = __system_property_area__;
 | 
				
			||||||
 | 
					    if (!pa) {
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Make sure this read fulfilled before __system_property_serial
 | 
				
			||||||
 | 
					    return atomic_load_explicit(&(pa->serial), memory_order_acquire);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const prop_info *__system_property_find(const char *name)
 | 
					const prop_info *__system_property_find(const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (__predict_false(compat_mode)) {
 | 
					    if (__predict_false(compat_mode)) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -98,6 +98,24 @@ int __system_property_set_filename(const char *filename);
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
int __system_property_area_init();
 | 
					int __system_property_area_init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Read the global serial number of the system properties
 | 
				
			||||||
 | 
					**
 | 
				
			||||||
 | 
					** Called to predict if a series of cached __system_property_find
 | 
				
			||||||
 | 
					** objects will have seen __system_property_serial values change.
 | 
				
			||||||
 | 
					** But also aids the converse, as changes in the global serial can
 | 
				
			||||||
 | 
					** also be used to predict if a failed __system_property_find
 | 
				
			||||||
 | 
					** could in-turn now find an new object; thus preventing the
 | 
				
			||||||
 | 
					** cycles of effort to poll __system_property_find.
 | 
				
			||||||
 | 
					**
 | 
				
			||||||
 | 
					** Called at the beginning of a cache cycle to signal _any_ possible
 | 
				
			||||||
 | 
					** changes have occurred since last. If there is, check each individual
 | 
				
			||||||
 | 
					** __system_property_serial to confirm dirty, or __system_property_find
 | 
				
			||||||
 | 
					** to check if the property now exists.
 | 
				
			||||||
 | 
					**
 | 
				
			||||||
 | 
					** Returns the serial number on success, -1 on error.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					unsigned int __system_property_area_serial();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Add a new system property.  Can only be done by a single
 | 
					/* Add a new system property.  Can only be done by a single
 | 
				
			||||||
** process that has write access to the property area, and
 | 
					** process that has write access to the property area, and
 | 
				
			||||||
** that process must handle sequencing to ensure the property
 | 
					** that process must handle sequencing to ensure the property
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user