€•o`Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ./translations/zh_CN/core-api/symbol-namespaces”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/zh_TW/core-api/symbol-namespaces”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/it_IT/core-api/symbol-namespaces”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/ja_JP/core-api/symbol-namespaces”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/ko_KR/core-api/symbol-namespaces”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ./translations/sp_SP/core-api/symbol-namespaces”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒSymbol Namespaces”h]”hŒSymbol Namespaces”…””}”(hh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒH/var/lib/git/docbuild/linux/Documentation/core-api/symbol-namespaces.rst”h KubhŒ paragraph”“”)”}”(hŒ©The following document describes how to use Symbol Namespaces to structure the export surface of in-kernel symbols exported through the family of EXPORT_SYMBOL() macros.”h]”hŒ©The following document describes how to use Symbol Namespaces to structure the export surface of in-kernel symbols exported through the family of EXPORT_SYMBOL() macros.”…””}”(hh¹hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khh£hžhubh¢)”}”(hhh]”(h§)”}”(hŒ Introduction”h]”hŒ Introduction”…””}”(hhÊhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hhÇhžhhŸh¶h K ubh¸)”}”(hX^Symbol Namespaces have been introduced as a means to structure the export surface of the in-kernel API. It allows subsystem maintainers to partition their exported symbols into separate namespaces. That is useful for documentation purposes (think of the SUBSYSTEM_DEBUG namespace) as well as for limiting the availability of a set of symbols for use in other parts of the kernel. As of today, modules that make use of symbols exported into namespaces, are required to import the namespace. Otherwise the kernel will, depending on its configuration, reject loading the module or warn about a missing import.”h]”hX^Symbol Namespaces have been introduced as a means to structure the export surface of the in-kernel API. It allows subsystem maintainers to partition their exported symbols into separate namespaces. That is useful for documentation purposes (think of the SUBSYSTEM_DEBUG namespace) as well as for limiting the availability of a set of symbols for use in other parts of the kernel. As of today, modules that make use of symbols exported into namespaces, are required to import the namespace. Otherwise the kernel will, depending on its configuration, reject loading the module or warn about a missing import.”…””}”(hhØhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K hhÇhžhubh¸)”}”(hŒ†Additionally, it is possible to put symbols into a module namespace, strictly limiting which modules are allowed to use these symbols.”h]”hŒ†Additionally, it is possible to put symbols into a module namespace, strictly limiting which modules are allowed to use these symbols.”…””}”(hhæhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KhhÇhžhubeh}”(h]”Œ introduction”ah ]”h"]”Œ introduction”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K ubh¢)”}”(hhh]”(h§)”}”(hŒHow to define Symbol Namespaces”h]”hŒHow to define Symbol Namespaces”…””}”(hhÿhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hhühžhhŸh¶h Kubh¸)”}”(hŒ¦Symbols can be exported into namespace using different methods. All of them are changing the way EXPORT_SYMBOL and friends are instrumented to create ksymtab entries.”h]”hŒ¦Symbols can be exported into namespace using different methods. All of them are changing the way EXPORT_SYMBOL and friends are instrumented to create ksymtab entries.”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h Khhühžhubh¢)”}”(hhh]”(h§)”}”(hŒUsing the EXPORT_SYMBOL macros”h]”hŒUsing the EXPORT_SYMBOL macros”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjhžhhŸh¶h K ubh¸)”}”(hXÔIn addition to the macros EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL(), that allow exporting of kernel symbols to the kernel symbol table, variants of these are available to export symbols into a certain namespace: EXPORT_SYMBOL_NS() and EXPORT_SYMBOL_NS_GPL(). They take one additional argument: the namespace as a string constant. Note that this string must not contain whitespaces. E.g. to export the symbol ``usb_stor_suspend`` into the namespace ``USB_STORAGE``, use::”h]”(hX–In addition to the macros EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL(), that allow exporting of kernel symbols to the kernel symbol table, variants of these are available to export symbols into a certain namespace: EXPORT_SYMBOL_NS() and EXPORT_SYMBOL_NS_GPL(). They take one additional argument: the namespace as a string constant. Note that this string must not contain whitespaces. E.g. to export the symbol ”…””}”(hj,hžhhŸNh NubhŒliteral”“”)”}”(hŒ``usb_stor_suspend``”h]”hŒusb_stor_suspend”…””}”(hj6hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hj,ubhŒ into the namespace ”…””}”(hj,hžhhŸNh Nubj5)”}”(hŒ``USB_STORAGE``”h]”hŒ USB_STORAGE”…””}”(hjHhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hj,ubhŒ, use:”…””}”(hj,hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K"hjhžhubhŒ literal_block”“”)”}”(hŒ2EXPORT_SYMBOL_NS(usb_stor_suspend, "USB_STORAGE");”h]”hŒ2EXPORT_SYMBOL_NS(usb_stor_suspend, "USB_STORAGE");”…””}”hjbsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j`hŸh¶h K*hjhžhubh¸)”}”(hXQThe corresponding ksymtab entry struct ``kernel_symbol`` will have the member ``namespace`` set accordingly. A symbol that is exported without a namespace will refer to ``NULL``. There is no default namespace if none is defined. ``modpost`` and kernel/module/main.c make use the namespace at build time or module load time, respectively.”h]”(hŒ'The corresponding ksymtab entry struct ”…””}”(hjrhžhhŸNh Nubj5)”}”(hŒ``kernel_symbol``”h]”hŒ kernel_symbol”…””}”(hjzhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjrubhŒ will have the member ”…””}”(hjrhžhhŸNh Nubj5)”}”(hŒ ``namespace``”h]”hŒ namespace”…””}”(hjŒhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjrubhŒN set accordingly. A symbol that is exported without a namespace will refer to ”…””}”(hjrhžhhŸNh Nubj5)”}”(hŒ``NULL``”h]”hŒNULL”…””}”(hjžhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjrubhŒ4. There is no default namespace if none is defined. ”…””}”(hjrhžhhŸNh Nubj5)”}”(hŒ ``modpost``”h]”hŒmodpost”…””}”(hj°hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjrubhŒa and kernel/module/main.c make use the namespace at build time or module load time, respectively.”…””}”(hjrhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K,hjhžhubeh}”(h]”Œusing-the-export-symbol-macros”ah ]”h"]”Œusing the export_symbol macros”ah$]”h&]”uh1h¡hhühžhhŸh¶h K ubh¢)”}”(hhh]”(h§)”}”(hŒ)Using the DEFAULT_SYMBOL_NAMESPACE define”h]”hŒ)Using the DEFAULT_SYMBOL_NAMESPACE define”…””}”(hjÓhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjÐhžhhŸh¶h K3ubh¸)”}”(hX7Defining namespaces for all symbols of a subsystem can be very verbose and may become hard to maintain. Therefore a default define (DEFAULT_SYMBOL_NAMESPACE) is been provided, that, if set, will become the default for all EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL() macro expansions that do not specify a namespace.”h]”hX7Defining namespaces for all symbols of a subsystem can be very verbose and may become hard to maintain. Therefore a default define (DEFAULT_SYMBOL_NAMESPACE) is been provided, that, if set, will become the default for all EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL() macro expansions that do not specify a namespace.”…””}”(hjáhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K5hjÐhžhubh¸)”}”(hXdThere are multiple ways of specifying this define and it depends on the subsystem and the maintainer's preference, which one to use. The first option is to define the default namespace in the ``Makefile`` of the subsystem. E.g. to export all symbols defined in usb-common into the namespace USB_COMMON, add a line like this to drivers/usb/common/Makefile::”h]”(hŒÂThere are multiple ways of specifying this define and it depends on the subsystem and the maintainer’s preference, which one to use. The first option is to define the default namespace in the ”…””}”(hjïhžhhŸNh Nubj5)”}”(hŒ ``Makefile``”h]”hŒMakefile”…””}”(hj÷hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j4hjïubhŒ— of the subsystem. E.g. to export all symbols defined in usb-common into the namespace USB_COMMON, add a line like this to drivers/usb/common/Makefile:”…””}”(hjïhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K:hjÐhžhubja)”}”(hŒ6ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE='"USB_COMMON"'”h]”hŒ6ccflags-y += -DDEFAULT_SYMBOL_NAMESPACE='"USB_COMMON"'”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jpjquh1j`hŸh¶h K@hjÐhžhubh¸)”}”(hX(That will affect all EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL() statements. A symbol exported with EXPORT_SYMBOL_NS() while this definition is present, will still be exported into the namespace that is passed as the namespace argument as this argument has preference over a default symbol namespace.”h]”hX(That will affect all EXPORT_SYMBOL() and EXPORT_SYMBOL_GPL() statements. A symbol exported with EXPORT_SYMBOL_NS() while this definition is present, will still be exported into the namespace that is passed as the namespace argument as this argument has preference over a default symbol namespace.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KBhjÐhžhubh¸)”}”(hŒ’A second option to define the default namespace is directly in the compilation unit as preprocessor statement. The above example would then read::”h]”hŒ‘A second option to define the default namespace is directly in the compilation unit as preprocessor statement. The above example would then read:”…””}”(hj+hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KGhjÐhžhubja)”}”(hŒ-#define DEFAULT_SYMBOL_NAMESPACE "USB_COMMON"”h]”hŒ-#define DEFAULT_SYMBOL_NAMESPACE "USB_COMMON"”…””}”hj9sbah}”(h]”h ]”h"]”h$]”h&]”jpjquh1j`hŸh¶h KJhjÐhžhubh¸)”}”(hŒŽwithin the corresponding compilation unit before the #include for . Typically it's placed before the first #include statement.”h]”hŒwithin the corresponding compilation unit before the #include for . Typically it’s placed before the first #include statement.”…””}”(hjGhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KLhjÐhžhubeh}”(h]”Œ)using-the-default-symbol-namespace-define”ah ]”h"]”Œ)using the default_symbol_namespace define”ah$]”h&]”uh1h¡hhühžhhŸh¶h K3ubh¢)”}”(hhh]”(h§)”}”(hŒ+Using the EXPORT_SYMBOL_FOR_MODULES() macro”h]”hŒ+Using the EXPORT_SYMBOL_FOR_MODULES() macro”…””}”(hj`hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hj]hžhhŸh¶h KPubh¸)”}”(hŒ¯Symbols exported using this macro are put into a module namespace. This namespace cannot be imported. These exports are GPL-only as they are only intended for in-tree modules.”h]”hŒ¯Symbols exported using this macro are put into a module namespace. This namespace cannot be imported. These exports are GPL-only as they are only intended for in-tree modules.”…””}”(hjnhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KRhj]hžhubh¸)”}”(hŒ‹The macro takes a comma separated list of module names, allowing only those modules to access this symbol. Simple tail-globs are supported.”h]”hŒ‹The macro takes a comma separated list of module names, allowing only those modules to access this symbol. Simple tail-globs are supported.”…””}”(hj|hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KVhj]hžhubh¸)”}”(hŒ For example::”h]”hŒ For example:”…””}”(hjŠhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KYhj]hžhubja)”}”(hŒ M=$PWD nsdeps”h]”hŒ,$ make -C M=$PWD nsdeps”…””}”hjósbah}”(h]”h ]”h"]”h$]”h&]”jpjquh1j`hŸh¶h K¥hjnhžhubh¸)”}”(hŒŠNote: it will happily generate an import statement for the module namespace; which will not work and generates build and runtime failures.”h]”hŒŠNote: it will happily generate an import statement for the module namespace; which will not work and generates build and runtime failures.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h K§hjnhžhubeh}”(h]”Œ2automatically-creating-module-import-ns-statements”ah ]”h"]”Œ2automatically creating module_import_ns statements”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K†ubeh}”(h]”Œsymbol-namespaces”ah ]”h"]”Œsymbol namespaces”ah$]”h&]”uh1h¡hhhžhhŸh¶h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h¶uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¦NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jBŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h¶Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jjhùhöjÁj¾jÍjÊjZjWj¹j¶j2j/jkjhjjuŒ nametypes”}”(j‰hù‰jÁ‰j͉jZ‰j¹‰j2‰jk‰j‰uh}”(jh£höhÇj¾hüjÊjjWjÐj¶j]j/jÄjhj5jjnuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.